idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
1,800 | public static function fromFloat ( $ float , $ tolerance = null ) { if ( $ float instanceof FloatType ) { $ float = $ float ( ) ; } if ( $ float == 0.0 ) { return new RationalType ( new IntType ( 0 ) , new IntType ( 1 ) ) ; } if ( $ tolerance instanceof FloatType ) { $ tolerance = $ tolerance ( ) ; } elseif ( is_null (... | Create a rational number from a float or FloatType Use Continued Fractions method of determining the rational number |
1,801 | protected static function createCorrectRational ( $ num , $ den ) { if ( self :: getRequiredType ( ) == self :: TYPE_GMP ) { return new GMPRationalType ( new GMPIntType ( $ num ) , new GMPIntType ( $ den ) ) ; } return new RationalType ( new IntType ( $ num ) , new IntType ( $ den ) ) ; } | Create and return the correct number type rational |
1,802 | private static function createFromNumericNumerator ( $ numerator , $ denominator ) { if ( is_null ( $ denominator ) ) { return self :: createCorrectRational ( $ numerator , 1 ) ; } if ( is_numeric ( $ denominator ) ) { return self :: createCorrectRational ( $ numerator , $ denominator ) ; } if ( $ denominator instanceo... | Create where numerator is known to be numeric |
1,803 | private static function throwCreateException ( $ numerator , $ denominator ) { $ typeN = gettype ( $ numerator ) ; $ typeD = gettype ( $ denominator ) ; throw new InvalidTypeException ( "{$typeN}:{$typeD} for Rational type construction" ) ; } | Throw a create exception |
1,804 | public static function getWorkingDaysCount ( $ beginDate , $ endDate , $ nonWorkingDays = [ ] ) { $ workdays = 0 ; if ( ! is_null ( $ beginDate ) && ! is_null ( $ endDate ) ) { if ( $ beginDate > $ endDate ) { $ temp = $ beginDate ; $ beginDate = $ endDate ; $ endDate = $ temp ; } $ oneDayInterval = new DateInterval ( ... | Count working days between the two given dates . The comparison includes both begin and end dates . |
1,805 | public static function getAverageTimeForArrayOfDateTimes ( $ array ) { if ( ! is_array ( $ array ) ) { return false ; } $ averageTime = null ; $ averageSecondsFromDateBeginSum = 0 ; $ processedItemsCounter = 0 ; foreach ( $ array as $ datetime ) { if ( ! is_object ( $ datetime ) || ! ( $ datetime instanceof \ DateTime ... | Method find the average time for given array of datetime objects it ignores any non DateTIme values in the given array |
1,806 | public function limit ( $ limit , $ skip = null ) { $ this -> pipeline [ '$limit' ] = $ limit ; if ( ! empty ( $ skip ) ) { $ this -> pipeline [ '$skip' ] = $ skip ; } return $ this ; } | Set the result limit and offset . |
1,807 | public function getResult ( ) { $ result = $ this -> mongo -> aggregate ( $ this -> getCollectionName ( ) , $ this -> getPipeline ( ) ) ; return $ result -> toArray ( ) ; } | This method does your query lookup and returns the result in form of an array . In case if there are no records to return false is returned . |
1,808 | public function sortByTimestamp ( $ direction ) { if ( $ this -> id != '$ts' ) { throw new AnalyticsDbException ( 'In order to sort by timestamp, you need to first group by timestamp.' ) ; } $ direction = ( int ) $ direction ; $ this -> pipeline [ '$sort' ] = [ '_id' => $ direction ] ; return $ this ; } | Sorts the result by timestamp . |
1,809 | public function sortByEntityName ( $ direction ) { if ( $ this -> id != '$entity' ) { throw new AnalyticsDbException ( 'In order to sort by entity name, you need to first group by entity name.' ) ; } $ direction = ( int ) $ direction ; $ this -> pipeline [ '$sort' ] = [ '_id' => $ direction ] ; return $ this ; } | Sorts the result by entity name . |
1,810 | public function sortByRef ( $ direction ) { if ( $ this -> id != '$ref' ) { throw new AnalyticsDbException ( 'In order to sort by ref, you need to first group by ref.' ) ; } $ direction = ( int ) $ direction ; $ this -> pipeline [ '$sort' ] = [ '_id' => $ direction ] ; return $ this ; } | Sorts the result by referrer value . |
1,811 | public function getPipeline ( ) { $ pipeline = [ ] ; foreach ( $ this -> pipeline as $ k => $ v ) { $ pipeline [ ] = [ $ k => $ v ] ; } return $ pipeline ; } | Returns the pipeline array . |
1,812 | public function config ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ id => $ val ) { $ this -> config ( $ id , $ val ) ; } } else { if ( ! is_null ( $ value ) ) { return $ this -> bind ( $ key , $ value ) ; } if ( $ this -> bound ( $ key ) ) { return $ this -> make ( $ key ) ; } else { $... | Get or set configuration values . |
1,813 | protected function get_engine_config ( ) { $ config = $ this -> prepare_engine_config ( ) ; $ locations = $ config [ 'locations' ] ; unset ( $ config [ 'locations' ] ) ; $ locations = array_filter ( ( array ) $ locations , function ( $ location ) { return file_exists ( $ location ) ; } ) ; return [ $ locations , $ conf... | Get engine config . |
1,814 | protected function prepare_config ( $ arr ) { $ result = [ ] ; if ( ! is_array ( $ arr ) ) { return $ result ; } $ arr = array_merge ( $ this -> get_default_config ( ) , $ arr ) ; foreach ( $ arr as $ key => $ value ) { $ res = $ this -> config ( $ key ) ; $ result [ $ key ] = is_null ( $ res ) ? $ value : $ res ; } re... | Prepare the template engines real configuration . |
1,815 | public function finish ( Lexer $ lexer ) { if ( is_array ( $ this -> exitPattern ) ) { foreach ( $ this -> exitPattern as $ exitPattern ) { $ lexer -> addExitPattern ( $ exitPattern , $ this -> name ) ; } } else { $ lexer -> addExitPattern ( $ this -> exitPattern , $ this -> name ) ; } return $ this ; } | Finish rule after connecting |
1,816 | protected function handleEndState ( $ content , $ position , TokenList $ tokenList ) { if ( ! empty ( $ content ) ) { $ tokenList -> addToken ( $ this -> name , $ position ) -> set ( 'content' , $ content ) ; } } | Handle lexers end state |
1,817 | public static function valid ( $ key , $ cipher ) { $ keyLength = mb_strlen ( $ key , '8bit' ) ; if ( static :: SUPPORTED_CIPHER_32_LENGTH === $ keyLength && $ cipher === static :: SUPPORTED_CIPHER_32 ) { return true ; } if ( static :: SUPPORTED_CIPHER_16_LENGTH == $ keyLength && $ cipher === static :: SUPPORTED_CIPHER... | Check if the given key and cipher have valid length and name . |
1,818 | public static function generateEncryptionKey ( $ cipher ) { if ( $ cipher === static :: SUPPORTED_CIPHER_32 ) { return random_bytes ( static :: SUPPORTED_CIPHER_32_LENGTH ) ; } if ( $ cipher === static :: SUPPORTED_CIPHER_16 ) { return random_bytes ( static :: SUPPORTED_CIPHER_16_LENGTH ) ; } } | Generate encryption key . |
1,819 | public function encrypt ( $ value ) { $ iv = random_bytes ( openssl_cipher_iv_length ( $ this -> cipher ) ) ; $ value = \ openssl_encrypt ( $ value , $ this -> cipher , $ this -> key , 0 , $ iv ) ; $ hash_mac = $ this -> mac ( $ iv = base64_encode ( $ iv ) , $ value ) ; if ( ! $ value ) { throw new Exception ( 'Unable ... | Encrypt the value . |
1,820 | public function decrypt ( $ data ) { $ data = json_decode ( base64_decode ( $ data ) , true ) ; $ iv = base64_decode ( $ data [ 'iv' ] ) ; if ( ! $ this -> isEncryptedDataValid ( $ data ) ) { throw new Exception ( 'The given encrypted data is invalid.' ) ; } if ( ! $ this -> isMacValid ( $ data , 16 ) ) { throw new Exc... | Decrypt the given data and return plain text . |
1,821 | protected function isMacValid ( $ data , $ bytes ) { $ calculated = hash_hmac ( 'sha384' , $ this -> mac ( $ data [ 'iv' ] , $ data [ 'value' ] ) , $ bytes , true ) ; return hash_equals ( hash_hmac ( 'sha384' , $ data [ 'hash_mac' ] , $ bytes , true ) , $ calculated ) ; } | Determine if hash is valid . |
1,822 | public function get ( ) { if ( $ this -> isInteger ( ) ) { return $ this -> value [ 'num' ] -> get ( ) ; } $ num = intval ( gmp_strval ( $ this -> value [ 'num' ] -> gmp ( ) ) ) ; $ den = intval ( gmp_strval ( $ this -> value [ 'den' ] -> gmp ( ) ) ) ; return $ num / $ den ; } | Get the value of the object typed properly as a PHP Native type |
1,823 | private function getMatchingIndex ( array $ matchingList , PreferenceInterface $ pref ) { $ index = - 1 ; foreach ( $ matchingList as $ key => $ match ) { if ( $ match -> getVariant ( ) === $ pref -> getVariant ( ) ) { $ index = $ key ; } } return $ index ; } | Returns the first index containing a matching variant or - 1 if not present . |
1,824 | public function execute ( $ path ) { $ parts = ( ! is_array ( $ path ) ) ? explode ( '.' , $ path ) : $ path ; $ source = $ this -> subject ; foreach ( $ parts as $ index => $ part ) { $ source = $ this -> resolve ( $ part , $ source ) ; } return $ source ; } | Execute the data search using the path provided |
1,825 | public function resolve ( $ part , $ source ) { if ( is_array ( $ source ) ) { $ source = $ this -> handleArray ( $ part , $ source ) ; } elseif ( is_object ( $ source ) ) { $ source = $ this -> handleObject ( $ part , $ source ) ; } return $ source ; } | Using the path part given locate the data on the current source |
1,826 | public function handleArray ( $ path , $ subject ) { $ set = [ ] ; foreach ( $ subject as $ subj ) { $ result = $ this -> resolve ( $ path , $ subj ) ; if ( is_array ( $ result ) ) { $ set = array_merge ( $ set , $ result ) ; } else { $ set = $ result ; } } return $ set ; } | Handle the location of the value when the source is an array |
1,827 | public function loadTranslations ( $ locale , $ package = 'default' ) { $ package = $ package ? : 'default' ; if ( empty ( static :: $ translations [ $ locale ] ) ) { $ fileName = $ locale . DIRECTORY_SEPARATOR . $ package . '.json' ; $ filePath = $ this -> getBaseDirectory ( ) . DIRECTORY_SEPARATOR . $ fileName ; if (... | Load translations from file . |
1,828 | public function is ( $ flag ) { if ( ! isset ( $ this -> _detectors [ $ flag ] ) ) { return $ flag === $ this -> format ( ) ; } $ detector = $ this -> _detectors [ $ flag ] ; if ( is_callable ( $ detector ) ) { return $ detector ( $ this ) ; } if ( ! is_array ( $ detector ) ) { throw new Exception ( "Invalid `'{$flag}'... | Provides a simple syntax for making assertions about the properties of a request . |
1,829 | public function locale ( $ locale = null ) { if ( $ locale ) { $ this -> _locale = $ locale ; } if ( $ this -> _locale ) { return $ this -> _locale ; } if ( isset ( $ this -> _params [ 'locale' ] ) ) { return $ this -> _params [ 'locale' ] ; } } | Sets or returns the current locale string . |
1,830 | public static function ingoing ( $ config = [ ] ) { $ config [ 'env' ] = isset ( $ config [ 'env' ] ) ? $ config [ 'env' ] : $ _SERVER ; if ( ! isset ( $ config [ 'env' ] [ 'REQUEST_URI' ] ) ) { throw new NetException ( "Missing `'REQUEST_URI'` environment variable, unable to create the main request." ) ; } if ( ! isse... | Creates a request extracted from CGI globals . |
1,831 | private function setDefaultManipulationInformation ( ) { $ this -> add_base_dn = $ this -> basedn_array [ 0 ] ; $ this -> add_dn = $ this -> dn ; $ this -> add_pw = $ this -> password ; $ this -> modify_method = "self" ; $ this -> modify_base_dn = $ this -> add_base_dn ; $ this -> modify_dn = $ this -> add_dn ; $ this ... | Sets the base DN and credentials for add and modify operations based on the search base DN and credentials . This is done to provide sensible defaults in case the specific setter methods are not invoked . |
1,832 | public function connect ( $ username = "" , $ password = "" ) { if ( ! extension_loaded ( 'ldap' ) ) { throw new LdapExtensionNotLoadedException ( ) ; } $ params = array ( 'hostname' => $ this -> host , 'base_dn' => $ this -> basedn , 'options' => [ ConnectionInterface :: OPT_PROTOCOL_VERSION => $ this -> version , ] ,... | Connects and binds to the LDAP server . An optional username and password can be supplied to override the default credentials . Returns whether the connection and binding was successful . |
1,833 | public function connectByDN ( $ dn , $ password = "" ) { if ( ! extension_loaded ( 'ldap' ) ) { throw new LdapExtensionNotLoadedException ( ) ; } $ params = array ( 'hostname' => $ this -> host , 'base_dn' => $ this -> basedn , 'options' => [ ConnectionInterface :: OPT_PROTOCOL_VERSION => $ this -> version , ] , ) ; if... | Connects and binds to the LDAP server based on the provided DN and an optional password . Returns whether the connection and binding were successful . |
1,834 | public function getAttributeFromResults ( $ results , $ attr_name ) { foreach ( $ results as $ node ) { if ( $ attr_name == "dn" ) { return $ node -> getDn ( ) ; } foreach ( $ node -> getAttributes ( ) as $ attribute ) { if ( strtolower ( $ attribute -> getName ( ) ) == strtolower ( $ attr_name ) ) { return $ attribute... | Returns the value of the specified attribute from the result set . Returns null if the attribute could not be found . |
1,835 | public function searchByAuth ( $ value ) { $ numArgs = substr_count ( $ this -> search_auth_query , "%s" ) ; $ args = array_fill ( 0 , $ numArgs , $ value ) ; $ searchStr = vsprintf ( $ this -> search_auth_query , $ args ) ; $ results = null ; foreach ( $ this -> basedn_array as $ basedn ) { if ( ! empty ( $ this -> ov... | Queries LDAP for the record with the specified value for attributes matching what could commonly be used for authentication . For the purposes of this method uid mail and mailLocalAddress are searched by default unless their values have been overridden . |
1,836 | public function searchByEmail ( $ email ) { $ results = $ this -> ldap -> search ( $ this -> basedn , $ this -> search_mail . '=' . $ email ) ; return $ results ; } | Queries LDAP for the record with the specified email . |
1,837 | public function searchByEmailArray ( $ email ) { $ results = $ this -> ldap -> search ( $ this -> basedn , $ this -> search_mail_array . '=' . $ email ) ; return $ results ; } | Queries LDAP for the record with the specified mailLocalAddress . |
1,838 | public function searchByQuery ( $ query ) { $ results = $ this -> ldap -> search ( $ this -> basedn , $ query ) ; return $ results ; } | Queries LDAP for the records using the specified query . |
1,839 | public function searchByUid ( $ uid ) { $ results = $ this -> ldap -> search ( $ this -> basedn , $ this -> search_username . '=' . $ uid ) ; return $ results ; } | Queries LDAP for the record with the specified uid . |
1,840 | public function addObject ( $ identifier , $ attributes ) { $ this -> bind ( $ this -> add_dn , $ this -> add_pw ) ; $ node = new Node ( ) ; if ( strpos ( $ identifier , ',' ) !== FALSE ) { $ dn = $ identifier ; } else { $ dn = $ this -> search_username . '=' . $ identifier . ',' . $ this -> add_base_dn ; } $ node -> s... | Adds an object into the add subtree using the specified identifier and an associative array of attributes . Returns a boolean describing whether the operation was successful . Throws an exception if the bind fails . |
1,841 | public function modifyObject ( $ identifier , $ attributes ) { if ( $ this -> modify_method != "self" ) { $ this -> bind ( $ this -> modify_dn , $ this -> modify_pw ) ; } if ( strpos ( $ identifier , ',' ) !== FALSE ) { $ dn = $ identifier ; } else { $ dn = $ this -> search_username . '=' . $ identifier . ',' . $ this ... | Modifies an object in the modify subtree using the specified identifier and an associative array of attributes . Returns a boolean describing whether the operation was successful . Throws an exception if the bind fails . |
1,842 | public function setAddBaseDN ( $ add_base_dn ) { if ( ! empty ( $ add_base_dn ) ) { $ this -> add_base_dn = $ add_base_dn ; } else { $ this -> add_base_dn = $ this -> basedn ; } } | Sets the base DN for add operations in a subtree . |
1,843 | public function setAddDN ( $ add_dn ) { if ( ! empty ( $ add_dn ) ) { $ this -> add_dn = $ add_dn ; } else { $ this -> add_dn = $ this -> dn ; } } | Sets the admin DN for add operations in a subtree . If the parameter is left empty the search admin DN will be used instead . |
1,844 | public function setAddPassword ( $ add_pw ) { if ( ! empty ( $ add_pw ) ) { $ this -> add_pw = $ add_pw ; } else { $ this -> add_pw = $ this -> password ; } } | Sets the admin password for add operations in a subtree . If the parameter is left empty the search admin password will be used instead . |
1,845 | public function setModifyBaseDN ( $ modify_base_dn ) { if ( ! empty ( $ modify_base_dn ) ) { $ this -> modify_base_dn = $ modify_base_dn ; } else { $ this -> modify_base_dn = $ this -> add_base_dn ; } } | Sets the base DN for modify operations in a subtree . If the parameter is left empty the add base DN will be used instead . |
1,846 | public function setModifyDN ( $ modify_dn ) { if ( ! empty ( $ modify_dn ) ) { $ this -> modify_dn = $ modify_dn ; } else { $ this -> modify_dn = $ this -> add_dn ; } } | Sets the admin DN for modify operations in a subtree . If the parameter is left empty the add admin DN will be used instead . |
1,847 | public function setModifyPassword ( $ modify_pw ) { if ( ! empty ( $ modify_pw ) ) { $ this -> modify_pw = $ modify_pw ; } else { $ this -> modify_pw = $ this -> add_pw ; } } | Sets the admin password for modify operations in a subtree . If the parameter is left empty the add admin password will be used instead . |
1,848 | protected function loadConfigFromFiles ( string ... $ configFiles ) { foreach ( $ configFiles as $ configFile ) { $ this -> config -> merge ( require $ configFile ) ; } } | Merges config params from service provider with the global configuration . |
1,849 | protected function provideCommands ( string ... $ commandClasses ) { $ commandCollector = $ this -> container -> get ( CommandCollection :: class ) ; foreach ( $ commandClasses as $ commandClass ) { $ commandCollector -> add ( $ commandClass ) ; } } | Registers commands exposed by service provider . |
1,850 | function post ( $ resource , $ payload = array ( ) , $ headers = array ( ) ) { $ result = $ this -> client -> post ( $ this -> build_url ( $ resource ) , [ 'headers' => array_merge ( [ 'Content-Type' => $ this -> getContentType ( ) , 'Authorization' => $ this -> getBearer ( ) , 'Content-Length' => ( ! count ( $ payload... | Build and make a POST request . |
1,851 | function delete ( $ resource , $ headers = array ( ) ) { $ result = $ this -> client -> delete ( $ this -> build_url ( $ resource ) , [ 'headers' => array_merge ( [ 'Authorization' => $ this -> getBearer ( ) ] , $ headers ) ] ) ; return $ result ; } | Build and make a DELETE request . |
1,852 | public function request ( $ method , $ url , $ params = array ( ) , $ vars = array ( ) ) { $ this -> request = curl_init ( ) ; $ this -> setRequestMethod ( $ method ) ; $ this -> setOptions ( $ url , $ method , $ params , $ vars ) ; $ data = curl_exec ( $ this -> request ) ; if ( $ data === false ) { throw new \ Except... | Executes a request |
1,853 | protected function setRequestMethod ( $ method ) { switch ( strtoupper ( $ method ) ) { case 'HEAD' : curl_setopt ( $ this -> request , CURLOPT_NOBODY , true ) ; break ; case 'GET' : curl_setopt ( $ this -> request , CURLOPT_CUSTOMREQUEST , 'GET' ) ; break ; case 'POST' : curl_setopt ( $ this -> request , CURLOPT_POST ... | Set the associated CURL options for a request method |
1,854 | protected function setOptions ( $ url , $ method , $ params , $ vars ) { if ( ! empty ( $ params ) ) { $ url = $ url . "?" . http_build_query ( $ params ) ; } curl_setopt ( $ this -> request , CURLOPT_URL , $ url ) ; curl_setopt ( $ this -> request , CURLOPT_HEADER , true ) ; curl_setopt ( $ this -> request , CURLOPT_R... | Set the CURL options |
1,855 | protected function setJSONPayload ( $ vars ) { $ this -> headers [ 'Content-Type' ] = 'application/json' ; $ this -> headers [ 'Content-Length' ] = 0 ; $ this -> headers [ 'Expect' ] = '' ; if ( ! empty ( $ vars ) ) { $ data = json_encode ( $ vars ) ; $ this -> headers [ 'Content-Length' ] = strlen ( $ data ) ; curl_se... | Set the JSON payload |
1,856 | public function format ( $ data ) { if ( ! $ data -> hasProperty ( 'meta' ) ) { return $ data ; } foreach ( $ data -> getProperty ( 'meta' ) as $ meta ) { $ regex = false ; if ( ! $ this -> metaKeyExists ( $ meta ) && ! ( $ regex = $ this -> metaKeyIsRegex ( $ meta ) ) ) { continue ; } if ( $ regex ) { $ property = $ t... | Format the meta fields from the given data . |
1,857 | protected function metaKeyIsRegex ( $ meta ) { if ( ! isset ( $ meta [ 'meta_key' ] ) ) { return false ; } return $ this -> pregMatchArray ( $ meta [ 'meta_key' ] , $ this -> regex ) ; } | Meta key is regex? |
1,858 | protected function getUnserializedValue ( $ meta ) { $ value = $ meta [ 'meta_value' ] ; if ( $ unserializedValue = @ unserialize ( $ value ) ) { $ value = $ unserializedValue ; } return $ value ; } | Get unserialized value . |
1,859 | private function processConfig ( ) { $ processor = new Processor ( ) ; $ coreConfig = Yaml :: parse ( file_get_contents ( __DIR__ . '/Resources/core_filters.yml' ) ) ; $ configs = array ( $ this -> config , $ coreConfig ) ; $ configuration = new StereoConfiguration ( ) ; $ processedConfiguration = $ processor -> proces... | Process configuration for registering tapes and filters . |
1,860 | public function dump ( ) { foreach ( $ this -> tapes as $ tape ) { if ( $ tape -> hasResponses ( ) ) { $ fileName = 'record_' . $ tape -> getName ( ) . '.json' ; $ content = $ this -> formatter -> encodeResponsesCollection ( $ tape -> getResponses ( ) ) ; $ this -> writer -> write ( $ fileName , $ content ) ; } } } | Dumps the tapes on disk . |
1,861 | public function getTapeContent ( $ name ) { $ tape = $ this -> getTape ( $ name ) ; if ( $ tape -> hasResponses ( ) ) { $ content = $ this -> formatter -> encodeResponsesCollection ( $ tape -> getResponses ( ) ) ; return $ content ; } return ; } | Returns the content of a specific tape without writing it to disk . |
1,862 | protected function buildTabsArray ( $ availableGroups , $ attachedGroups ) { $ addGroupItems = [ ] ; $ tabs = [ ] ; foreach ( $ availableGroups as $ id => $ name ) { if ( ! in_array ( $ id , $ attachedGroups ) ) { $ addGroupItems [ $ id ] = $ name ; } $ isAttached = in_array ( $ id , $ attachedGroups ) ; if ( $ isAttac... | Build array for tabs . |
1,863 | public function packageExists ( $ namespace , $ package ) { $ folder = $ this -> vendorFolder . $ namespace ; $ folderExists = file_exists ( $ folder ) ; if ( ! $ folderExists ) { return false ; } $ packageFolder = $ folder . '/' . $ package ; $ packageFolderExists = file_exists ( $ packageFolder ) ; return $ packageFo... | Determine if a composer package exists . |
1,864 | public function onBeforeSend ( Event $ event ) { $ request = $ event [ 'request' ] ; list ( $ newUrl , $ port ) = $ this -> proxify ( $ request -> getUrl ( ) , $ this -> bucketKey , $ this -> gatewayHost ) ; $ request -> setUrl ( $ newUrl ) ; if ( $ port ) { $ request -> setHeader ( 'Runscope-Request-Port' , $ port ) ;... | Event triggered right before sending a request |
1,865 | public function add_action ( $ hook , $ component , $ callback , $ priority = 10 , $ accepted_args = 1 ) { $ this -> actions = $ this -> add ( $ this -> actions , $ hook , $ component , $ callback , $ priority , $ accepted_args ) ; } | Add a new action to the collection to be registered with WordPress . |
1,866 | public function add_filter ( $ hook , $ component , $ callback , $ priority = 10 , $ accepted_args = 1 ) { $ this -> filters = $ this -> add ( $ this -> filters , $ hook , $ component , $ callback , $ priority , $ accepted_args ) ; } | Add a new filter to the collection to be registered with WordPress . |
1,867 | public function run ( ) { foreach ( $ this -> filters as $ hook ) { add_filter ( $ hook [ 'hook' ] , array ( $ hook [ 'component' ] , $ hook [ 'callback' ] ) , $ hook [ 'priority' ] , $ hook [ 'accepted_args' ] ) ; } foreach ( $ this -> actions as $ hook ) { add_action ( $ hook [ 'hook' ] , array ( $ hook [ 'component'... | Register the filters and actions with WordPress . |
1,868 | public function getTranslations ( $ language , $ instance , $ parent_instance = false ) { $ sql = <<<TRANSLATIONS SELECT id, message, comment, SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as dest... | Returns the translations list for a given langauge . |
1,869 | public function getStats ( $ instance , $ parent_instance ) { $ parent_instance_sql = '' ; $ parent_instance_sub_sql = 'm.instance = ? OR t.instance = ?' ; if ( $ parent_instance ) { $ parent_instance_sql = ' OR instance IS NULL ' ; $ parent_instance_sub_sql = '( m.instance = ? OR m.instance IS NULL ) AND ( t.instance ... | Get stats of translations . |
1,870 | public function addMessage ( $ message , $ instance = null ) { $ sql = <<<SQLINSERT INTO i18n_messagesSET message = ?, instance = ?SQL ; return $ this -> Execute ( $ sql , array ( 'tag' => 'Add message' , $ message , $ instance ) ) ; } | Add message in database . |
1,871 | protected function buildMessage ( array $ allowedMethods ) : string { $ ending = 'Allowed method is: %s' ; if ( count ( $ allowedMethods ) > 1 ) { $ ending = 'Allowed methods are: %s' ; } return sprintf ( 'Method is not allowed. ' . $ ending , implode ( ', ' , $ allowedMethods ) ) ; } | Builds error message |
1,872 | public function accepts ( ) { $ accepts = $ this -> hasHeader ( 'Accept' ) ? $ this -> getHeader ( 'Accept' ) : [ 'text/html' ] ; foreach ( $ accepts as $ i => $ value ) { list ( $ mime , $ q ) = preg_split ( '/;\s*q\s*=\s*/' , $ value , 2 ) + [ $ value , 1.0 ] ; $ stars = substr_count ( $ mime , '*' ) ; $ score = $ st... | Return information about the mime of content that the client is requesting . |
1,873 | public function url ( ) { $ scheme = $ this -> scheme ( ) ; $ scheme = $ scheme ? $ scheme . '://' : '//' ; $ query = $ this -> query ( ) ? '?' . http_build_query ( $ this -> query ( ) ) : '' ; $ fragment = $ this -> fragment ( ) ? '#' . $ this -> fragment ( ) : '' ; return $ scheme . $ this -> host ( ) . $ this -> pat... | Returns the message URI . |
1,874 | public function credential ( ) { if ( ! $ username = $ this -> username ( ) ) { return '' ; } $ credentials = $ username ; if ( $ password = $ this -> password ( ) ) { $ credentials .= ':' . $ password ; } return $ credentials ; } | Returns the credential . |
1,875 | public function requestTarget ( ) { if ( $ this -> method ( ) === 'CONNECT' || $ this -> mode ( ) === 'authority' ) { $ credential = $ this -> credential ( ) ; return ( $ credential ? $ credential . '@' : '' ) . $ this -> host ( ) ; } if ( $ this -> mode ( ) === 'absolute' ) { return $ this -> url ( ) ; } if ( $ this -... | Returns the request target present in the status line . |
1,876 | public function auth ( $ auth = true ) { $ headers = $ this -> headers ( ) ; if ( $ auth === false ) { unset ( $ headers [ 'Authorization' ] ) ; } if ( ! $ auth ) { return ; } if ( is_array ( $ auth ) && ! empty ( $ auth [ 'nonce' ] ) ) { $ data = [ 'method' => $ this -> method ( ) , 'uri' => $ this -> path ( ) ] ; $ d... | Sets the request authorization . |
1,877 | public function applyCookies ( $ cookies ) { $ values = [ ] ; foreach ( $ cookies as $ cookie ) { if ( $ cookie -> matches ( $ this -> url ( ) ) ) { $ values [ $ cookie -> path ( ) ] = $ cookie -> name ( ) . '=' . $ cookie -> value ( ) ; } } $ keys = array_map ( 'strlen' , array_keys ( $ values ) ) ; array_multisort ( ... | Set the Cookie header |
1,878 | public function cookieValues ( ) { $ headers = $ request -> headers ( ) ; return isset ( $ headers [ 'Cookie' ] ) ? CookieValues :: toArray ( $ headers [ 'Cookie' ] -> value ( ) ) : [ ] ; } | Extract cookies value . |
1,879 | public static function create ( $ method = 'GET' , $ url = null , $ config = [ ] ) { if ( func_num_args ( ) ) { if ( ! preg_match ( '~^(?:[a-z]+:)?//~i' , $ url ) || ! $ defaults = parse_url ( $ url ) ) { throw new NetException ( "Invalid url: `'{$url}'`." ) ; } $ defaults [ 'username' ] = isset ( $ defaults [ 'user' ]... | Creates a request instance using an absolute URL . |
1,880 | public function addTo ( $ address , $ name = null ) { $ address = $ this -> _addRecipient ( 'To' , $ address , $ name ) ; $ this -> _recipients [ $ address -> email ( ) ] = $ address ; return $ this ; } | Add an email recipient . |
1,881 | public function addCc ( $ address , $ name = null ) { $ address = $ this -> _addRecipient ( 'Cc' , $ address , $ name ) ; $ this -> _recipients [ $ address -> email ( ) ] = $ address ; return $ this ; } | Adds carbon copy email recipient . |
1,882 | public function addBcc ( $ address , $ name = null ) { $ class = $ this -> _classes [ 'address' ] ; $ bcc = new $ class ( $ address , $ name ) ; $ this -> _recipients [ $ bcc -> email ( ) ] = $ bcc ; return $ this ; } | Adds blind carbon copy email recipient . |
1,883 | protected function _addRecipient ( $ type , $ address , $ name = null ) { $ classes = $ this -> _classes ; $ headers = $ this -> headers ( ) ; if ( ! isset ( $ headers [ $ type ] ) ) { $ addresses = $ classes [ 'addresses' ] ; $ headers [ $ type ] = new $ addresses ( ) ; } $ class = $ classes [ 'address' ] ; $ value = ... | Add a recipient to a specific type section . |
1,884 | public function addInline ( $ path , $ name = null , $ mime = true , $ encoding = true ) { $ cid = static :: generateId ( $ this -> client ( ) ) ; $ filename = basename ( $ path ) ; $ this -> _inlines [ $ path ] = [ 'filename' => $ name ? : $ filename , 'disposition' => 'attachment' , 'mime' => $ mime , 'headers' => [ ... | Add an embedded file . |
1,885 | public function addAttachment ( $ path , $ name = null , $ mime = true , $ encoding = true ) { $ cid = static :: generateId ( $ this -> client ( ) ) ; $ filename = basename ( $ path ) ; $ this -> _attachments [ $ path ] = [ 'filename' => $ name ? : $ filename , 'disposition' => 'attachment' , 'mime' => $ mime , 'header... | Add an attachment . |
1,886 | public function html ( $ body , $ basePath = null ) { if ( ! func_num_args ( ) ) { return $ this -> _body ; } if ( $ basePath ) { $ cids = [ ] ; $ hasInline = preg_match_all ( '~ (<img[^<>]*\s src\s*=\s* |<body[^<>]*\s background\s*=\s* |<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[... | Set the HTML body message with an optionnal alternative body . |
1,887 | public static function stripTags ( $ html , $ charset = 'UTF-8' ) { $ patterns = [ '~<(style|script|head).*</\\1>~Uis' => '' , '~<t[dh][ >]~i' => ' $0' , '~<a\s[^>]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)</a>~is' => '$2 <$1>' , '~[\r\n ]+~' => ' ' , '~<(/?p|/?h\d|li|br|/tr)[ >/]~i' => "\n$0" , ] ; $ text = pre... | Strip HTML tags |
1,888 | protected function initializeProperties ( $ properties = null ) { $ this -> getPropertiesInfo ( ) ; $ initializeValueValidationEnabled = Configuration :: isInitializeValuesValidationEnabled ( ) ; foreach ( $ this -> _initialPropertiesValues as $ propertyName => $ initialization ) { $ value = null ; switch ( $ initializ... | Initializes the object according to its class specification and given arguments . |
1,889 | private function updateInitializedPropertyValue ( $ propertyName , $ value ) { if ( empty ( $ this -> _collectionsItemNames [ 'byProperty' ] [ $ propertyName ] ) ) { $ this -> updatePropertyAssociation ( $ propertyName , array ( "oldValue" => null , "newValue" => $ value ) ) ; } else { foreach ( $ value as $ newValue )... | Update an initialized value . |
1,890 | protected function delete_vulnerabilities ( ) { $ query = new WP_Query ( [ 'fields' => 'ids' , 'no_found_rows' => true , 'post_type' => 'soter_vulnerability' , 'post_status' => 'private' , 'posts_per_page' => - 1 , 'update_post_meta_cache' => false , 'update_post_term_cache' => false , ] ) ; foreach ( $ query -> posts ... | Deletes any lingering soter_vulnerability posts . |
1,891 | protected function prepare_ignored_plugins ( array $ plugins ) { if ( ! function_exists ( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php' ; } $ valid_slugs = array_map ( function ( $ file ) { if ( false === strpos ( $ file , '/' ) ) { $ slug = basename ( $ file , '.php' ) ; } else { $ slug = d... | Ensure ignored plugins setting only contains currently installed plugins . |
1,892 | protected function prepare_ignored_themes ( array $ themes ) { $ valid_slugs = array_values ( wp_list_pluck ( wp_get_themes ( ) , 'stylesheet' ) ) ; return array_values ( array_intersect ( $ valid_slugs , $ themes ) ) ; } | Ensure ignored themes setting only contains currently installed themes . |
1,893 | protected function upgrade_to_050 ( ) { if ( $ this -> options -> installed_version ) { return ; } $ this -> upgrade_cron ( ) ; $ this -> upgrade_options ( ) ; $ this -> upgrade_results ( ) ; $ this -> delete_vulnerabilities ( ) ; $ this -> options -> get_store ( ) -> set ( 'installed_version' , '0.5.0' ) ; } | Required logic for upgrading to v0 . 5 . 0 . |
1,894 | protected function upgrade_options ( ) { $ old_options = ( array ) $ this -> options -> get_store ( ) -> get ( 'settings' , [ ] ) ; if ( isset ( $ old_options [ 'email_address' ] ) ) { $ sanitized = sanitize_email ( $ old_options [ 'email_address' ] ) ; if ( $ sanitized ) { $ this -> options -> get_store ( ) -> set ( '... | Upgrade to latest options implementation . |
1,895 | public function create ( $ device , array $ tagNames = array ( ) ) { if ( ! empty ( $ tagNames ) ) { $ tagEndpoint = new Tags ( $ this -> client ) ; $ tags = $ tagEndpoint -> findAll ( $ tagNames ) ; if ( ! empty ( $ tags [ 'notFound' ] ) ) { foreach ( $ tags [ 'notFound' ] as $ name ) { $ tags [ 'tags' ] [ ] = $ tagEn... | Create a device |
1,896 | public function tokenize ( string $ input ) : TokenStream { $ this -> prepare ( $ input ) ; while ( $ this -> cursor < $ this -> end ) { $ this -> currentChar = $ this -> input [ $ this -> cursor ] ; if ( preg_match ( '@' . Token :: REGEX_T_EOL . '@' , $ this -> currentChar ) ) { if ( $ this -> mode !== self :: MODE_ID... | Tokenizes a string into a TokenStream |
1,897 | private function prepare ( string $ input ) { $ this -> input = str_replace ( [ "\n\r" , "\r" ] , "\n" , $ input ) ; $ this -> stream = new TokenStream ( ) ; $ this -> cursor = 0 ; $ this -> line = 1 ; $ this -> lineOffset = 0 ; $ this -> end = strlen ( $ this -> input ) ; $ this -> lastCharPos = $ this -> end - 1 ; $ ... | Prepares the Lexer for tokenizing a string |
1,898 | private function setMode ( int $ mode ) { $ this -> mode = $ mode ; $ this -> modeStartLine = $ this -> line ; $ this -> modeStartPosition = $ this -> getCurrentLinePosition ( ) ; } | Sets the lexing mode |
1,899 | protected function addManager ( $ fileInfo , & $ mikado ) { $ manager = new Manager ( ) ; $ pathParts = pathinfo ( $ fileInfo -> getBasename ( ) ) ; $ model = $ pathParts [ 'filename' ] ; $ this -> addFormatter ( $ manager , $ model , 'MetaFormatter' ) ; $ this -> addFormatter ( $ manager , $ model , 'RemapFormatter' )... | Add manager to mikado . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.