idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
3,400 | private function flatten ( ? array $ arr , string $ group , ? string $ lang = null ) : ? array { if ( $ arr === null ) { return null ; } if ( ! isset ( $ this -> arrayGroups [ $ group ] ) ) { throw new \ OutOfBoundsException ( "Invalid group: $group" ) ; } if ( $ lang === null ) { $ lang = $ this -> lang ; } if ( ! iss... | Flattens an array group |
3,401 | public function save ( ) { foreach ( $ this -> data as $ key => $ value ) { if ( ! empty ( $ value ) ) { $ this -> parametersStorage -> set ( $ key , $ value ) ; } else { $ this -> parametersStorage -> remove ( $ key ) ; } } } | Save current model in the storage |
3,402 | private function registerConfig ( ) { $ this -> getContainer ( ) [ Config :: CONTAINER_ID ] = function ( Container $ di ) { $ loader = $ di [ ConfigLoaderInterface :: CONTAINER_ID ] ; $ params = $ loader -> load ( ) ; $ config = new Config ( ) ; $ config -> setParams ( $ params ) ; return $ config ; } ; } | Register the config to the DI container |
3,403 | public function getRepository ( DocumentManager $ documentManager , $ modelName , $ collectionName , CacheProvider $ repositoryCache = null ) { $ repIndex = $ modelName . $ collectionName ; if ( false != ( $ repository = $ this -> cache -> fetch ( $ repIndex ) ) ) { return $ repository ; } $ classMetadata = $ this -> c... | Get a repository |
3,404 | private function createCollection ( DocumentManager $ documentManager , ClassMetadata $ classMetadata , $ collectionName ) { $ database = $ documentManager -> getDatabase ( ) ; $ exists = false ; foreach ( $ database -> listCollections ( ) as $ collection ) { if ( $ collection -> getName ( ) == $ collectionName ) { $ e... | Create the collection |
3,405 | protected function getOptions ( $ level ) { $ lineBreak = "\r\n" ; $ intendChar = "\t" ; $ intendNum = 1 ; $ baseIntend = str_repeat ( $ intendChar , $ intendNum * $ level ) ; $ nextIntend = str_repeat ( $ intendChar , $ intendNum * ( $ level + 1 ) ) ; $ extraLineBreak = ( $ level === 0 ? $ lineBreak : '' ) ; return [ ... | Gets the options for the CSS generation . |
3,406 | public function execute ( $ pipelineName = null ) { $ request = $ this -> requestFactory -> newIncomingRequest ( ) ; if ( $ this -> adaptor -> isDoublePass ( ) ) { $ response = $ this -> responseFactory -> newResponse ( ) ; } else { $ response = null ; } return $ this -> chain ( $ pipelineName , $ request , $ response ... | Create and execute the named pipeline as an initial entry pipeline . |
3,407 | public function addMethodCall ( $ methodName ) { $ arguments = func_get_args ( ) ; array_shift ( $ arguments ) ; $ this -> methodCalls [ ] = new MethodCall ( $ methodName , $ arguments ) ; return $ this ; } | Set a method to be called after instantiating the class . |
3,408 | private function readNumber ( ) { if ( false === $ this -> handle = fopen ( $ this -> path , 'c+' ) ) { throw new RuntimeException ( "Failed to open file {$this->path}." ) ; } if ( ! flock ( $ this -> handle , LOCK_EX ) ) { throw new RuntimeException ( "Failed to lock file {$this->path}." ) ; } if ( false !== $ number ... | Reads the previous number . |
3,409 | private function writeNumber ( $ number ) { if ( ! ftruncate ( $ this -> handle , 0 ) ) { throw new RuntimeException ( "Failed to truncate file {$this->path}." ) ; } if ( 0 > fseek ( $ this -> handle , 0 ) ) { throw new RuntimeException ( "Failed to move pointer at the beginning of the file {$this->path}." ) ; } if ( !... | Writes the new number . |
3,410 | private function _output ( ) { $ output = \ wp_cache_get ( $ this -> key , $ this -> group ) ; if ( $ output !== false ) { echo $ output ; return true ; } ob_start ( ) ; return false ; } | Outputs cached content if available otherwise begins capturing output for caching . |
3,411 | private function _store ( ) { $ output = ob_get_flush ( ) ; \ wp_cache_add ( $ this -> key , $ output , $ this -> group , $ this -> expires ) ; } | Stores the rendered snippet in the object cache . |
3,412 | public static function extIs ( $ value ) { return static :: is ( $ value ) || ( is_string ( $ value ) && ( strval ( intval ( $ value ) ) === strval ( $ value ) ) ) ; } | Tests if the given value is an int or a string representation of an int . |
3,413 | public static function compare ( $ int1 , $ int2 ) { if ( ! static :: is ( $ int1 ) || ! static :: is ( $ int2 ) ) { throw new \ InvalidArgumentException ( "The \$int1 and \$int2 parameters must be of type int." ) ; } return ( $ int1 - $ int2 ) ; } | Compares two int values . |
3,414 | public static function random ( $ min = 0 , $ max = 1 , $ seed = null ) { if ( ! static :: is ( $ min ) || ! static :: is ( $ max ) ) { throw new \ InvalidArgumentException ( "The \$min and \$max parameters must be of type int." ) ; } if ( $ min > $ max ) { trigger_error ( "The \$min value cannot be greater than the \$... | Generates a random integer number between min and max . |
3,415 | protected function registerApiHelper ( Application $ app ) { $ app -> singleton ( Factory :: class , function ( $ app ) { $ request = $ app [ 'request' ] ; $ config = $ app [ 'config' ] ; return new Factory ( $ request , $ config ) ; } ) ; $ app -> alias ( Factory :: class , 'apihelper' ) ; } | Register the helper class . |
3,416 | public static function autoCreateDirectory ( $ path_name ) { if ( ! File :: exists ( dirname ( $ path_name ) ) ) { $ isMadeDir = mkdir ( dirname ( $ path_name ) , 0777 , true ) ; if ( ! $ isMadeDir ) { return false ; } } return true ; } | auto create directory if not exists |
3,417 | public function getUser ( ConnectionInterface $ con = null ) { if ( $ this -> aUser === null && ( $ this -> user_id !== null ) ) { $ this -> aUser = ChildUserQuery :: create ( ) -> findPk ( $ this -> user_id , $ con ) ; } return $ this -> aUser ; } | Get the associated ChildUser object |
3,418 | public function getRole ( ConnectionInterface $ con = null ) { if ( $ this -> aRole === null && ( $ this -> role_id !== null ) ) { $ this -> aRole = ChildRoleQuery :: create ( ) -> findPk ( $ this -> role_id , $ con ) ; } return $ this -> aRole ; } | Get the associated ChildRole object |
3,419 | public function setOrderParameters ( $ idAttr , $ orderAttr , $ labelAttr ) { $ this -> orderParameters = [ 'idAttr' => $ idAttr , 'orderAttr' => $ orderAttr , 'labelAttr' => $ labelAttr ] ; return $ this ; } | Sets the Ordered list param . |
3,420 | private function setMapAction ( ) { array_push ( $ this -> actions , 'map' ) ; $ this -> addForm = array_diff ( $ this -> addForm , [ 'map_lat' , 'map_lng' , 'map_address' , 'map_province' , 'map_locality' , 'map_postal_code' ] ) ; $ this -> editForm = array_diff ( $ this -> addForm , [ 'map_lat' , 'map_lng' , 'map_add... | Set map action |
3,421 | private function setFileAction ( ) { array_push ( $ this -> actions , 'file' ) ; $ this -> addForm = array_diff ( $ this -> addForm , [ 'files' ] ) ; $ this -> editForm = array_diff ( $ this -> addForm , [ 'files' ] ) ; $ this -> setModelDefaults ( 'files' , [ ] ) ; $ this -> setColumnFormat ( 'files' , 'files' ) ; ret... | Set file action |
3,422 | public function getPhoto ( $ photoId ) { $ resource = '/photos/' . $ photoId ; $ response = $ this -> makeApiRequest ( $ resource ) ; return $ response -> photo ; } | Check a user to a photo and maybe to a event too . |
3,423 | public static function compare ( $ float1 , $ float2 ) { if ( ! static :: is ( $ float1 ) || ! static :: is ( $ float2 ) ) { throw new \ InvalidArgumentException ( "The \$float1 and \$float2 parameters must be of type float." ) ; } return ( $ float1 - $ float2 ) ; } | Compares two float values . |
3,424 | public static function random ( $ min = 0.0 , $ max = 1.0 , $ round = null , $ seed = null ) { if ( ! static :: is ( $ min ) || ! static :: is ( $ max ) ) { throw new \ InvalidArgumentException ( "The \$min and \$max parameters must be of type float." ) ; } if ( $ min > $ max ) { trigger_error ( "The \$min value cannot... | Generates a random float number between min and max . |
3,425 | private function setColour ( $ colour ) { if ( ! in_array ( $ colour , $ this -> getDefaultColours ( ) ) && ! preg_match ( '_^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$_' , $ colour ) ) { throw new InvalidColourException ( sprintf ( 'The colour "%s" is not a valid colour. Possible options are "%s" or a valid hex colour' , $ col... | Set the colour if it is a valid colour . |
3,426 | public function request ( string $ request_uri = null , string $ request_method = 'GET' , array $ args = [ ] , array $ cookie = [ ] ) { self :: $ core -> deinit ( ) -> reset ( ) ; self :: $ core -> config ( 'home' , '/' ) ; $ _SERVER [ 'REQUEST_URI' ] = $ request_uri ? $ request_uri : '/' ; $ _SERVER [ 'REQUEST_METHOD'... | Fake request . |
3,427 | private function prepareLogsDir ( $ logsDir ) { if ( ! is_dir ( $ logsDir ) ) { if ( false === @ mkdir ( $ logsDir , 0777 , true ) && ! is_dir ( $ logsDir ) ) { throw new \ RuntimeException ( sprintf ( "Unable to create the logs directory (%s)\n" , $ logsDir ) ) ; } } elseif ( ! is_writable ( $ logsDir ) ) { throw new ... | Create logs dir if does not exist . |
3,428 | public function _before ( TestInterface $ test ) { if ( $ this -> config [ 'reconnect' ] ) { $ this -> connect ( ) ; } $ this -> removeInserted ( ) ; parent :: _before ( $ test ) ; } | Code to run before each test |
3,429 | public function _after ( TestInterface $ test ) { if ( $ this -> config [ 'reconnect' ] ) { $ this -> disconnect ( ) ; } parent :: _after ( $ test ) ; } | Code to run after each test |
3,430 | public function grabValueFromAerospike ( $ key ) { $ akey = $ this -> buildKey ( $ key ) ; $ status = $ this -> aerospike -> get ( $ akey , $ data ) ; if ( $ status != \ Aerospike :: OK ) { $ this -> fail ( strtr ( "[:errno:] Unable to grab ':key:' from the database: :error:" , [ ':errno:' => $ this -> aerospike -> err... | Grabs value from Aerospike by key . |
3,431 | public function seeInAerospike ( $ key , $ value = false ) { $ akey = $ this -> buildKey ( $ key ) ; $ status = $ this -> aerospike -> get ( $ akey , $ actual ) ; if ( $ status != \ Aerospike :: OK ) { $ this -> fail ( strtr ( "[:errno:] Unable to get ':key:' from the database: :error:" , [ ':errno:' => $ this -> aeros... | Checks item in Aerospike exists and the same as expected . |
3,432 | public function dontSeeInAerospike ( $ key , $ value = false ) { $ akey = $ this -> buildKey ( $ key ) ; if ( $ value === false ) { $ status = $ this -> aerospike -> get ( $ akey , $ record ) ; $ this -> assertSame ( \ Aerospike :: ERR_RECORD_NOT_FOUND , $ status ) ; return ; } $ this -> aerospike -> get ( $ akey , $ a... | Checks item in Aerospike does not exist or is the same as expected . |
3,433 | public function haveInAerospike ( $ key , $ value , $ ttl = 0 ) { $ akey = $ this -> buildKey ( $ key ) ; $ bins = [ 'value' => $ value ] ; $ status = $ this -> aerospike -> put ( $ akey , $ bins , $ ttl , [ \ Aerospike :: OPT_POLICY_KEY => \ Aerospike :: POLICY_KEY_SEND ] ) ; if ( $ status != \ Aerospike :: OK ) { $ t... | Inserts data into Aerospike database . |
3,434 | protected function buildKey ( $ key ) { return $ this -> aerospike -> initKey ( $ this -> config [ 'namespace' ] , $ this -> config [ 'set' ] , $ this -> config [ 'prefix' ] . $ key ) ; } | Generates a unique key used for storing cache in Aerospike DB . |
3,435 | public function file_permissions ( $ file ) { $ numeric_perms = fileperms ( $ file ) ; $ octal_perms = sprintf ( '%o' , $ numeric_perms ) ; return substr ( $ octal_perms , - 4 ) ; } | Returns the file permissions in octal format . |
3,436 | protected function arbitrate ( NumericTypeInterface $ a , NumericTypeInterface $ b ) { $ pairing = $ this -> getTypePairing ( $ a , $ b ) ; if ( $ pairing == 'complex:complex' ) { return 'complex' ; } if ( strpos ( $ pairing , 'complex' ) === 0 ) { return 'complex:numeric' ; } if ( strpos ( $ pairing , 'complex' ) !== ... | Arbitrate the return type from the operation |
3,437 | private function getTypePairing ( NumericTypeInterface $ a , NumericTypeInterface $ b ) { $ search = [ 'Chippyash\Type\Number\Rational\\' , 'Chippyash\Type\Number\Complex\\' , 'Chippyash\Type\Number\\' , 'Type' ] ; $ replace = [ '' , '' , '' , '' ] ; $ tA = strtolower ( str_replace ( $ search , $ replace , get_class ( ... | Work out the type of the number pairs |
3,438 | public static function render ( Query \ Insert $ query ) { return Compiler :: withDb ( $ query -> getDb ( ) , function ( ) use ( $ query ) { $ table = $ query -> getTable ( ) ; $ select = $ query -> getSelect ( ) ; return Compiler :: expression ( array ( 'INSERT' , $ query -> getType ( ) , Compiler :: word ( 'INTO' , $... | Render a Insert object |
3,439 | public function binaryUuid ( $ column = 'id' , $ primary = true ) { $ column = $ this -> addColumn ( 'binaryuuid' , $ column , [ 'length' => 16 ] ) ; if ( $ primary ) { $ column -> primary ( ) ; } return $ column ; } | Ajoute une column de type binary UUID |
3,440 | public function stringId ( $ column = 'id' , $ size = 32 , $ primary = true ) { $ column = $ this -> string ( $ column , $ size ) ; if ( $ primary ) { $ column -> primary ( ) ; } return $ column ; } | Ajoute une colonne id de type string |
3,441 | public function getDirectoryTreeList ( ) { $ finder = new Finder ( ) ; $ finder -> in ( $ this -> rootPath ) -> directories ( ) ; $ directories = array ( ) ; $ rootFinder = new Finder ( ) ; $ rootFinder -> in ( $ this -> rootPath ) -> depth ( 0 ) ; $ directories [ ] = new Directory ( $ this -> virtualRootPath , $ rootF... | Return the directory tree in the form of a list |
3,442 | private function getRealPath ( $ path ) { if ( strpos ( $ path , '../' ) !== false ) { throw new AccessDeniedException ( 'Path cannot contain "../" pattern' ) ; } return str_replace ( $ this -> virtualRootPath , $ this -> rootPath , $ path ) ; } | Return local path from remote query |
3,443 | public function routeSave ( MvcEvent $ event ) { $ match = $ event -> getRouteMatch ( ) ; if ( ! $ match ) { return ; } if ( $ event -> getParam ( 'route-cached' ) || ! $ event -> getParam ( 'route-cacheable' ) ) { return ; } $ path = $ event -> getRequest ( ) -> getUri ( ) -> getPath ( ) ; $ cache = $ event -> getAppl... | Method that tries to save a route match into a cache system |
3,444 | public function find ( $ id ) { return new self ( $ this -> _user , self :: get ( $ this -> _user , $ id ) ) ; } | Class method to find a Subscription |
3,445 | public function findAll ( $ page = 1 , $ per_page = 20 , $ order_by = self :: ORDERBY_CREATED_AT , $ order_dir = self :: ORDERDIR_ASC ) { $ results = self :: getAll ( $ this -> _user , $ page , $ per_page , $ order_by , $ order_dir ) ; if ( isset ( $ results [ 'subscriptions' ] ) ) { $ results = $ results [ 'subscripti... | Class method to find all Subscriptions |
3,446 | public static function get ( $ user , $ id = false ) { $ params = array ( ) ; if ( $ id ) { $ params [ 'id' ] = $ id ; } return $ user -> get ( 'pylon/get' , $ params ) ; } | Get an existing recordings . |
3,447 | private function load ( $ data ) { if ( empty ( $ data ) ) { throw new DataSift_Exception_InvalidData ( 'No data found' ) ; } foreach ( $ data as $ key => $ value ) { $ this -> { '_' . $ key } = $ value ; } } | Loads an pylon object from the get data |
3,448 | public function reload ( ) { if ( strlen ( $ this -> _id ) == 0 ) { throw new DataSift_Exception_InvalidData ( 'Unable to reload pylon without an ID' ) ; } $ this -> load ( self :: get ( $ this -> _user , $ this -> _id ) ) ; } | Updates the object with fresh results from get |
3,449 | public function compile ( $ csdl = false ) { if ( $ csdl ) { $ this -> _csdl = $ csdl ; } if ( strlen ( $ this -> _csdl ) == 0 ) { throw new DataSift_Exception_InvalidData ( 'Cannot compile an empty definition.' ) ; } $ res = $ this -> _user -> post ( 'pylon/compile' , array ( 'csdl' => $ this -> _csdl ) ) ; $ this -> ... | Compiles the CSDL of this object |
3,450 | public function start ( $ hash = false , $ name = false ) { if ( $ hash ) { $ this -> _hash = $ hash ; } if ( $ name ) { $ this -> _name = $ name ; } if ( ! empty ( $ this -> _id ) ) { $ this -> restart ( ) ; } else { $ this -> create ( ) ; } } | Creates a new recording or restarts an existing one if an ID is present |
3,451 | public function restart ( $ id = false ) { if ( $ id ) { $ this -> _id = $ id ; } $ this -> _user -> put ( 'pylon/start' , array ( 'id' => $ this -> _id ) ) ; } | Restarts the pylon recording |
3,452 | public function stop ( $ id = false ) { if ( $ id ) { $ this -> _id = $ id ; } if ( strlen ( $ this -> _id ) == 0 ) { throw new DataSift_Exception_InvalidData ( 'Unable to reload pylon without an ID' ) ; } $ this -> _user -> post ( 'pylon/stop' , array ( 'id' => $ this -> _id ) ) ; } | Stops the pylon recording |
3,453 | public function analyze ( $ parameters , $ filter = false , $ start = false , $ end = false , $ id = false ) { if ( $ id ) { $ this -> _id = $ id ; } if ( ! is_array ( $ parameters ) ) { $ parameters = json_decode ( $ parameters ) ; } if ( empty ( $ parameters ) ) { throw new DataSift_Exception_InvalidData ( 'Parameter... | Analyze the recording |
3,454 | public function tags ( $ id = false ) { if ( $ id ) { $ this -> _id = $ id ; } if ( strlen ( $ this -> _id ) == 0 ) { throw new DataSift_Exception_InvalidData ( 'Unable to get tags without an ID' ) ; } return $ this -> _user -> get ( 'pylon/tags' , array ( 'id' => $ this -> _id ) ) ; } | Analyze the tags in the data set |
3,455 | public function update ( $ id = false , $ hash = false , $ name = false ) { if ( $ id ) { $ this -> _id = $ id ; } if ( $ hash ) { $ this -> _hash = $ hash ; } if ( $ name ) { $ this -> _name = $ name ; } $ params = array ( 'id' => $ this -> _id , 'hash' => $ this -> _hash , 'name' => $ this -> _name ) ; $ this -> _use... | Updates a recording with a new hash and or name |
3,456 | public function applyRequestQueryParams ( AbstractPaginator $ paginator ) { foreach ( array_except ( Request :: instance ( ) -> query -> all ( ) , [ self :: PAGINATION_CURRENT_PAGE , self :: PAGINATION_PER_PAGE ] ) as $ key => $ value ) { $ paginator -> addQuery ( $ key , $ value ) ; } $ paginator -> addQuery ( self ::... | Find all the query parameters passed in the request and apply them to the paginator so we can build a useful URL . |
3,457 | protected function checkCache ( $ name ) { if ( ! isset ( $ this -> cache [ $ name ] ) ) { try { $ config = $ this -> db -> from ( $ this -> table ) -> where ( $ this -> columns [ 'name' ] ) -> eq ( $ name ) -> select ( ) -> fetchAssoc ( ) -> first ( ) ; if ( ! $ config ) { return false ; } $ this -> cache [ $ name ] =... | Check if an item was cached |
3,458 | public function write ( $ name , $ value ) { $ path = explode ( '.' , $ name ) ; $ key = array_shift ( $ path ) ; $ exists = $ this -> checkCache ( $ key ) ; if ( $ path ) { if ( ! $ exists ) { $ this -> cache [ $ key ] = new ArrayHelper ( ) ; } $ this -> cache [ $ key ] -> set ( $ path , $ value ) ; } else { $ this ->... | Write config data |
3,459 | public function read ( $ name , $ default = null ) { $ path = explode ( '.' , $ name ) ; $ key = array_shift ( $ path ) ; if ( $ this -> checkCache ( $ key ) ) { return $ path ? $ this -> cache [ $ key ] -> get ( $ path , $ default ) : $ this -> cache [ $ key ] -> toArray ( ) ; } return $ default ; } | Read config data |
3,460 | public function has ( $ name ) { $ path = explode ( '.' , $ name ) ; $ key = array_shift ( $ path ) ; if ( $ this -> checkCache ( $ key ) ) { return $ path ? $ this -> cache [ $ key ] -> has ( $ path ) : true ; } return false ; } | Check if the config exists |
3,461 | public function delete ( $ name ) { $ path = explode ( '.' , $ name ) ; $ key = array_shift ( $ path ) ; if ( $ path ) { if ( $ this -> checkCache ( $ key ) && $ this -> cache [ $ key ] -> delete ( $ path ) ) { return $ this -> updateRecord ( $ key ) ; } return false ; } unset ( $ this -> cache [ $ key ] ) ; return $ t... | Delete a config |
3,462 | public function params ( ... $ params ) : self { $ this -> params = $ params ; array_push ( $ this -> params , $ this -> event ) ; return $ this ; } | All arguments passed to this method will be forwarded to callback functions of all listeners |
3,463 | public function cachedData ( ) { if ( ! $ this -> isCached ( ) ) { return null ; } $ contents = file_get_contents ( $ this -> file ) ; $ serializationEnabled = static :: config ( 'serialize' ) ; $ data = $ serializationEnabled ? unserialize ( $ contents ) : $ contents ; return $ data ; } | Retrieves the cached data that is refered by this object |
3,464 | public static function clearAll ( ) { $ dir = new \ DirectoryIterator ( static :: config ( 'directory' ) ) ; foreach ( $ dir as $ fileinfo ) { if ( $ fileinfo -> isFile ( ) ) { $ cacheKey = $ fileinfo -> getFilename ( ) ; static :: clear ( $ cacheKey ) ; } } } | Clear all the cache data stored in the cache directory |
3,465 | public static function countAll ( ) { $ count = 0 ; $ dir = new \ DirectoryIterator ( static :: config ( 'directory' ) ) ; foreach ( $ dir as $ fileinfo ) { if ( $ fileinfo -> isFile ( ) ) { $ count ++ ; } } return $ count ; } | Returns the total number of unique cached data |
3,466 | public static function slugify ( $ text , $ lowercase = true , $ skip_chars = '' ) { $ text = preg_replace ( '~[^\\pL\d' . $ skip_chars . ']+~u' , '-' , $ text ) ; $ text = trim ( $ text , '-' ) ; $ text = iconv ( 'utf-8' , 'us-ascii//TRANSLIT' , $ text ) ; if ( $ lowercase ) $ text = strtolower ( $ text ) ; $ text = p... | Convert a string to friendly SEO string |
3,467 | public static function set_values ( $ defaults , $ values , $ default_key = "" ) { if ( $ default_key != "" ) { if ( ! is_array ( $ values ) ) { if ( isset ( $ defaults [ $ default_key ] ) ) $ defaults [ $ default_key ] = $ values ; return $ defaults ; } } if ( $ values ) { foreach ( $ values as $ key => $ value ) { if... | Set values from default properties of an array |
3,468 | public static function read_csv ( $ filename , $ with_header = true , $ headers = null , $ delimiter = ',' ) { $ data = [ ] ; $ index = 0 ; $ header_count = $ headers ? count ( $ headers ) : 0 ; $ handle = @ fopen ( $ filename , "r" ) or false ; if ( $ handle !== FALSE ) { while ( ( $ row = fgetcsv ( $ handle , 0 , $ d... | Read CSV from URL or File |
3,469 | public static function parse_email ( $ str , $ separator = "," ) { $ str = trim ( preg_replace ( '/\s+/' , ' ' , $ str ) ) ; $ all = [ ] ; $ emails = preg_split ( '/(".*?"\s*<.+?>)\s*' . $ separator . '*|' . $ separator . '+/' , $ str , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; foreach ( $ emails as $ em... | Parse email address string |
3,470 | public static function get_session_info ( ) { $ browser_info = get_browser_info ( ) ; $ result = new stdClass ; $ result -> ip = get_client_ip ( ) ; $ result -> browser_info = ( object ) $ browser_info ; return $ result ; } | Store client session info to an object |
3,471 | public static function get_client_ip ( ) { $ ipaddress = '' ; if ( getenv ( 'HTTP_CLIENT_IP' ) ) $ ipaddress = getenv ( 'HTTP_CLIENT_IP' ) ; else if ( getenv ( 'HTTP_X_FORWARDED_FOR' ) ) $ ipaddress = getenv ( 'HTTP_X_FORWARDED_FOR' ) ; else if ( getenv ( 'HTTP_X_FORWARDED' ) ) $ ipaddress = getenv ( 'HTTP_X_FORWARDED'... | Get the client s IP Address |
3,472 | public static function get_browser_info ( ) { $ u_agent = isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : 'UNKNOWN' ; $ bname = 'Unknown' ; $ platform = 'Unknown' ; $ ub = 'Unknown' ; $ version = "" ; if ( preg_match ( '/linux/i' , $ u_agent ) ) { $ platform = 'linux' ; } elseif ( preg_mat... | Get your browser s info |
3,473 | public static function encrypt ( $ data , $ key , $ iv ) { $ output = false ; $ encrypt_method = "AES-256-CBC" ; $ key = hash_hmac ( 'sha256' , $ data , $ iv ) ; $ iv = substr ( $ iv , 0 , 16 ) ; $ output = openssl_encrypt ( $ data , $ encrypt_method , $ key , 0 , $ iv ) ; $ output = base64_encode ( $ output ) ; return... | Returns an base64 encoded encrypted string |
3,474 | public static function decrypt ( $ data , $ key , $ iv ) { $ output = false ; $ encrypt_method = "AES-256-CBC" ; $ key = hash_hmac ( 'sha256' , $ data , $ iv ) ; $ iv = substr ( $ iv , 0 , 16 ) ; $ output = openssl_decrypt ( base64_decode ( $ data ) , $ encrypt_method , $ key , 0 , $ iv ) ; return $ output ; } | Returns decrypted original string |
3,475 | public static function to_array ( $ object ) { if ( is_array ( $ object ) ) return $ object ; if ( ! is_object ( $ object ) && ! is_array ( $ object ) ) return $ object ; if ( is_object ( $ object ) ) $ object = get_object_vars ( $ object ) ; return array_map ( [ __CLASS__ , 'to_array' ] , $ object ) ; } | Convert an object to an array |
3,476 | public static function zip ( $ files = [ ] , $ destination = '' , $ overwrite = false ) { if ( file_exists ( $ destination ) && ! $ overwrite ) { return false ; } $ valid_files = [ ] ; $ files = is_array ( $ files ) ? $ files : [ $ files ] ; if ( $ files ) { foreach ( $ files as $ filename => $ file ) { if ( file_exist... | Create a compressed zip file |
3,477 | public function init ( ) { $ this -> version = $ this -> read ( true ) ; if ( ! $ this -> login ( ) ) return false ; return true ; } | Initializes Connection and Log s In |
3,478 | public function connect ( & $ cn = 1 , & $ cs = "Unknown error" ) { $ fp = fsockopen ( $ this -> ip , $ this -> port , $ cn , $ cs , 3 ) or die ( "Could not connect. " . date ( "Y-m-d H:i:s" ) . PHP_EOL ) ; if ( ! $ fp ) { return false ; } else { self :: $ socket = $ fp ; return true ; } } | Connect with server |
3,479 | protected function login ( ) { return $ this -> query ( 'login ' . md5 ( substr ( $ this -> read ( true ) , 17 ) . $ this -> pwd ) ) == 'Authentication successful, rcon ready.' ; } | Tries to Login |
3,480 | public static function query ( $ line , $ bare = false ) { self :: write ( $ line , $ bare ) ; if ( strpos ( $ result = self :: read ( $ bare ) , 'rcon: unknown command:' ) === 0 ) return false ; return $ result ; } | Executes a Query on the Server |
3,481 | protected static function read ( $ bare = false ) { $ delim = $ bare ? "\n" : "\x04" ; for ( $ buffer = '' ; ( $ char = fgetc ( self :: $ socket ) ) != $ delim ; $ buffer .= $ char ) ; return trim ( $ buffer ) ; } | Reads the Buffer |
3,482 | private function cleanOrderBy ( $ table , $ orderBy ) { if ( ! empty ( $ orderBy ) ) { $ orderByArray = explode ( ',' , $ orderBy ) ; foreach ( $ orderByArray as $ k => $ order ) { $ orderByArray [ $ k ] = $ table . '.' . $ order ; } $ orderBy = implode ( ',' , $ orderByArray ) ; } return $ orderBy ; } | Cleans order by clause |
3,483 | protected function mergeRecords ( array $ records ) { foreach ( $ records as $ key => $ record ) { if ( null === $ id = array_get ( $ record , static :: ID_FIELD ) ) { throw new InternalServerErrorException ( 'No ' . static :: ID_FIELD . ' field found in supplied record(s). Cannot merge record(s) for PATCH operation.' ... | Merges new record with existing record to perform PATCH operation |
3,484 | public static function getProperty ( $ object , string $ propertyName ) { $ reflection = new \ ReflectionObject ( $ object ) ; $ property = $ reflection -> getProperty ( $ propertyName ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( $ object ) ; } | Reads also private and protected properties |
3,485 | public function parse ( $ pattern ) { $ lexer = $ this -> createLexer ( ) ; try { $ result = $ lexer -> lex ( $ pattern ) ; } catch ( LexingException $ e ) { $ message = sprintf ( 'Lexing failed with error: %s' , $ e -> getMessage ( ) ) ; throw new TokenizeException ( $ message , 0 , $ e ) ; } if ( $ lexer -> hasPushed... | Parses the pattern to produce an array of token identifiers . |
3,486 | protected function createInitialDefinition ( ) { return [ '[^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*|(?:\\\\.[^\\\\*\[?]*)+' => self :: T_WORD , '\*' => self :: T_WILDCARD_MULTI , '\?' => self :: T_WILDCARD_SINGLE , '\[([!^]?)(?=(\])?)' => function ( Stateful $ lexer , $ matches ) { $ state = isset ( $ matches [ 2 ] ) ? 'IN_G... | Initial state . This is the default state when the lexer enters the pattern . |
3,487 | protected function createInGroupDefinition ( ) { return [ '\]' => function ( Stateful $ lexer ) { $ lexer -> popState ( ) ; return self :: T_GROUP_END ; } , '.-[^\]]' => self :: T_GROUP_RANGE , '\[:[a-z]+:\]' => self :: T_GROUP_CHARACTER_CLASS , '.' => self :: T_GROUP_CHARACTER ] ; } | In group state . This looks for standard characters ranges and POSIX character classes . |
3,488 | public function execute ( $ eventName , $ object ) { if ( isset ( $ this -> events [ $ eventName ] ) && is_array ( ( $ this -> events [ $ eventName ] ) ) ) { foreach ( $ this -> events [ $ eventName ] as $ method ) { call_user_func ( [ $ object , $ method ] ) ; } } } | Execute an event |
3,489 | protected function filter ( & $ value ) { if ( is_scalar ( $ value ) ) { return htmlspecialchars ( $ value , ENT_QUOTES | ENT_SUBSTITUTE , 'UTF-8' ) ; } elseif ( is_array ( $ value ) ) { array_walk_recursive ( $ value , [ $ this , 'filter' ] ) ; } elseif ( is_object ( $ value ) ) { foreach ( get_object_vars ( $ value )... | Filters a variable reference for XSS . |
3,490 | public function getFileUsage ( ) { if ( empty ( $ this -> fileUsage ) ) { $ this -> fileUsage = \ Drupal :: service ( 'file.usage' ) ; } return $ this -> fileUsage ; } | Gets file usage service . |
3,491 | public function createImagesFromVideos ( $ source , $ target = 'step-%03d.jpg' ) { try { $ this -> serviceLocator -> setShared ( 'playgroundcore_phpvideotoolkit' , false ) ; $ this -> serviceLocator -> get ( 'playgroundcore_phpvideotoolkit' ) -> addPreInputCommand ( '-y' ) -> addCommand ( '-i' , $ source ) -> setOutput... | This method create images from a video . ffmpeg - i input . mov output_%03d . png |
3,492 | public function convertToMp3 ( $ source , $ target ) { $ this -> serviceLocator -> setShared ( 'playgroundcore_phpvideotoolkit' , false ) ; $ this -> serviceLocator -> get ( 'playgroundcore_phpvideotoolkit' ) -> addPreInputCommand ( '-y' ) -> addCommand ( '-i' , $ source ) -> addCommand ( '-vn' ) -> addCommand ( '-ar' ... | ffmpeg - i sound . avi - vn - ar 44100 - ac 2 - ab 192 - f mp3 out . mp3 |
3,493 | protected static function invalidateCache ( $ id ) { $ type = static :: getType ( ) ; $ id = ( string ) $ id ; static :: initializeCache ( $ type ) ; $ collection = self :: $ cache -> { $ type } ; unset ( $ collection -> { $ id } ) ; } | Remove resource from cache used by PUT PATCH and DELETE methods when changing an object |
3,494 | public function id ( ) : string { if ( null !== $ this -> id ) { return $ this -> id ; } if ( $ this -> headers -> contain ( 'HTTP_X_REQUEST_ID' ) ) { $ this -> id = $ this -> readHeader ( 'HTTP_X_REQUEST_ID' ) -> ifMatches ( '~^([a-zA-Z0-9+/=-]{20,200})$~' ) ; } if ( null === $ this -> id ) { $ this -> id = substr ( s... | returns id of the request |
3,495 | public function protocolVersion ( ) { if ( ! $ this -> headers -> contain ( 'SERVER_PROTOCOL' ) ) { return new HttpVersion ( 1 , 0 ) ; } try { return HttpVersion :: fromString ( $ this -> headers -> value ( 'SERVER_PROTOCOL' ) -> value ( ) ) ; } catch ( \ InvalidArgumentException $ ex ) { return null ; } } | returns HTTP protocol version of request |
3,496 | public function originatingIpAddress ( ) { try { if ( $ this -> headers -> contain ( 'HTTP_X_FORWARDED_FOR' ) ) { $ remoteAddresses = explode ( ',' , $ this -> headers -> value ( 'HTTP_X_FORWARDED_FOR' ) -> value ( ) ) ; return new IpAddress ( trim ( $ remoteAddresses [ 0 ] ) ) ; } if ( $ this -> headers -> contain ( '... | returns the ip address which issued the request originally |
3,497 | public function userAgent ( array $ botSignatures = [ ] ) : UserAgent { return new UserAgent ( $ this -> headers -> value ( 'HTTP_USER_AGENT' ) -> value ( ) , $ this -> cookies -> count ( ) > 0 , $ botSignatures ) ; } | returns the user agent which issued the request |
3,498 | public function uri ( ) : HttpUri { $ host = ( string ) $ this -> headers -> value ( 'HTTP_HOST' ) -> value ( ) ; return HttpUri :: fromParts ( $ this -> headers -> contain ( 'HTTPS' ) ? Http :: SCHEME_SSL : Http :: SCHEME , $ host , strstr ( $ host , ':' ) === false ? $ this -> headers -> value ( 'SERVER_PORT' ) -> va... | returns the uri of the request |
3,499 | public function hasRedirectHeader ( string $ headerName ) : bool { return $ this -> hasHeader ( 'REDIRECT_' . $ headerName ) || $ this -> hasHeader ( $ headerName ) ; } | checks whether a request header or it s redirect equivalent is set |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.