idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
240,600 | public function oneOf ( $ allowed , $ message = null ) { if ( is_string ( $ allowed ) ) { $ allowed = explode ( ',' , $ allowed ) ; } $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { return in_array ( $ val , $ args [ 0 ] ) ; } , $ message , array ( $ allowed ) ) ; return $ this ; } | Field has to be one of the allowed ones . |
240,601 | protected function _applyFilter ( & $ val ) { if ( is_array ( $ val ) ) { foreach ( $ val as $ key => & $ item ) { $ this -> _applyFilter ( $ item ) ; } } else { foreach ( $ this -> filters as $ filter ) { $ val = $ filter ( $ val ) ; } } } | recursively apply filters to a value |
240,602 | protected function _validate ( $ key , $ val ) { foreach ( $ this -> rules as $ rule => $ is_true ) { if ( $ is_true ) { $ function = $ this -> functions [ $ rule ] ; $ args = $ this -> arguments [ $ rule ] ; $ valid = true ; if ( is_array ( $ val ) ) { foreach ( $ val as $ v ) { $ valid = $ valid && ( empty ( $ args )... | recursively validates a value |
240,603 | public function getAllErrors ( $ keys = true ) { return ( $ keys == true ) ? $ this -> errors : array_values ( $ this -> errors ) ; } | Get all errors . |
240,604 | protected function registerError ( $ rule , $ key , $ message = null ) { if ( empty ( $ message ) ) { $ message = $ this -> messages [ $ rule ] ; } $ this -> errors [ $ key ] = sprintf ( $ message , $ this -> fields [ $ key ] ) ; } | Register error . |
240,605 | public function setRule ( $ rule , $ function , $ message = '' , $ args = array ( ) ) { if ( ! array_key_exists ( $ rule , $ this -> rules ) ) { $ this -> rules [ $ rule ] = TRUE ; if ( ! array_key_exists ( $ rule , $ this -> functions ) ) { if ( ! is_callable ( $ function ) ) { die ( 'Invalid function for rule: ' . $ ... | Set rule . |
240,606 | public static function getClasses ( $ namespace , $ conditions = [ ] ) { self :: _setupRoot ( ) ; $ namespace = explode ( '\\' , trim ( $ namespace , '\\' ) ) ; $ composerNamespaces = self :: getComposerNamespaces ( ) ; $ searchPaths = [ ] ; foreach ( $ composerNamespaces as $ ns => $ paths ) { $ nsTrimmed = explode ( ... | Return a list of classes under a given namespace . It is an error to enumerate the root namespace . |
240,607 | public static function getComposerModule ( $ className ) { global $ Composer ; if ( $ result = $ Composer -> findFile ( $ className ) ) { $ result = substr ( $ result , strlen ( self :: $ root ) ) ; if ( preg_match ( '#^vendor/([a-z0-9_-]+/[a-z0-9_-]+)/#' , $ result , $ match ) ) { return $ match [ 1 ] ; } } return nul... | Return the name of the composer module where a given class lives . |
240,608 | private static function getComposerNamespaces ( ) { static $ result = null ; if ( ! is_array ( $ result ) ) { $ result = require self :: $ root . 'vendor/composer/autoload_namespaces.php' ; foreach ( $ result as $ ns => & $ paths ) { $ subpath = trim ( str_replace ( '\\' , DIRECTORY_SEPARATOR , $ ns ) , DIRECTORY_SEPAR... | Get Composer s namespace list . |
240,609 | private static function searchPath ( $ prefix , $ path , $ conditions ) { $ result = [ ] ; $ dir = new DirectoryIterator ( $ path ) ; foreach ( $ dir as $ entry ) { if ( $ entry -> isDot ( ) ) { continue ; } $ de = $ entry -> getFilename ( ) ; if ( $ entry -> isDir ( ) && preg_match ( '/^[A-Za-z_]+$/' , $ de ) ) { $ re... | Search one directory recursively for classes belonging to a given namespace . |
240,610 | private static function _setupRoot ( ) { if ( ! empty ( self :: $ root ) ) { return ; } if ( defined ( 'ROOT' ) ) { self :: $ root = rtrim ( ROOT , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; } else if ( ! empty ( $ GLOBALS [ 'baseDir' ] ) ) { self :: $ root = rtrim ( $ GLOBALS [ 'baseDir' ] , DIRECTORY_SEPARATOR ) .... | Determine the project root directory . |
240,611 | public static function URI ( ) { $ REDIRECT_QUERY_STRING = isset ( $ _SERVER [ 'QUERY_STRING' ] ) ? $ _SERVER [ 'QUERY_STRING' ] : '' ; $ REDIRECT_URL = '' ; if ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ url_parts = parse_url ( $ _SERVER [ 'REQUEST_URI' ] ) ; $ REDIRECT_URL = $ url_parts [ 'path' ] ; } $ URI = rtrim... | Get current URI and GET parameters from the requested URI |
240,612 | private function codeToMessage ( $ code ) { switch ( $ code ) { case \ Th \ FileDownloader :: FILE_WRONG_MIME : $ message = "File is of the wrong MIME type" ; break ; case \ Th \ FileDownloader :: FILE_WRONG_EXTENSION : $ message = "File is of the wrong extension" ; break ; case \ Th \ FileDownloader :: INVALID_DOWNLOA... | Method that switches the error code constants till it finds the messages that belongs to the error code and then returns the message . |
240,613 | public function isAWS ( ) { return in_array ( $ this -> type ( ) , [ TargetEnum :: TYPE_CD , TargetEnum :: TYPE_EB , TargetEnum :: TYPE_S3 ] ) ; } | Is this group for AWS? |
240,614 | public function formatParameters ( ) { switch ( $ this -> type ( ) ) { case TargetEnum :: TYPE_CD : return $ this -> parameter ( 'group' ) ? : '???' ; case TargetEnum :: TYPE_EB : return $ this -> parameter ( 'environment' ) ? : '???' ; case TargetEnum :: TYPE_S3 : $ bucket = $ this -> parameter ( 'bucket' ) ? : '???' ... | Format parameters into something readable . |
240,615 | public function handle ( ServerRequestInterface $ request ) : ResponseInterface { if ( $ this -> index >= count ( $ this -> middlewares ) ) { throw new OutOfBoundsException ( 'Reached end of middleware stack. Does your controller return a response ?' ) ; } $ middleware = $ this -> middlewares [ $ this -> index ++ ] ; r... | Execute the middleware stack . |
240,616 | private static function parseXml ( \ Gettext \ Translations $ translations , $ realPath , $ shownPath ) { if ( @ filesize ( $ realPath ) !== 0 ) { $ xml = new \ DOMDocument ( ) ; if ( $ xml -> load ( $ realPath ) === false ) { global $ php_errormsg ; if ( isset ( $ php_errormsg ) && $ php_errormsg ) { throw new \ Excep... | Parses an XML CIF file and extracts translatable strings . |
240,617 | private static function readXmlNodeAttribute ( \ Gettext \ Translations $ translations , $ filenameRel , \ DOMNode $ node , $ attributeName , $ context = '' ) { $ value = ( string ) $ node -> getAttribute ( $ attributeName ) ; if ( $ value !== '' ) { $ translation = $ translations -> insert ( $ context , $ value ) ; $ ... | Parse a node attribute and create a POEntry item if it has a value . |
240,618 | private static function readXmlPageKeywords ( \ Gettext \ Translations $ translations , $ filenameRel , \ DOMNode $ node , $ pageUrl ) { $ keywords = ( string ) $ node -> nodeValue ; if ( $ keywords !== '' ) { $ translation = $ translations -> insert ( '' , $ keywords ) ; $ translation -> addReference ( $ filenameRel ,... | Parse a node attribute which contains the keywords for a page . |
240,619 | private static function parseXmlNodeValue ( \ Gettext \ Translations $ translations , $ filenameRel , \ DOMNode $ node , $ context = '' ) { $ value = ( string ) $ node -> nodeValue ; if ( $ value !== '' ) { $ translation = $ translations -> insert ( $ context , $ value ) ; $ translation -> addReference ( $ filenameRel ... | Parse a node value and create a POEntry item if it has a value . |
240,620 | public function dirs ( array $ dirs ) { foreach ( $ dirs as $ k => $ v ) { if ( is_numeric ( $ v ) ) { $ this -> dir ( $ k , $ v ) ; continue ; } $ this -> dir ( $ v ) ; } return $ this ; } | Add directories to clean . |
240,621 | protected function cleanDir ( $ dir , $ keep ) { $ finder = clone $ this -> finder ; $ finder -> in ( $ dir ) ; $ finder -> depth ( 0 ) ; $ this -> doSort ( $ finder ) ; $ items = iterator_to_array ( $ finder -> getIterator ( ) ) ; if ( $ keep ) { array_splice ( $ items , - $ keep ) ; } while ( $ items ) { $ item = res... | Clean a directory . |
240,622 | protected function doSort ( Finder $ finder ) { switch ( $ this -> sort ) { case static :: SORT_NAME : $ finder -> sortByName ( ) ; break ; case static :: SORT_TYPE : $ finder -> sortByType ( ) ; break ; case static :: SORT_ACCESS_TIME : $ finder -> sortByAccessedTime ( ) ; break ; case static :: SORT_MODIFIED_TIME : $... | Sort the finder . |
240,623 | protected function setup ( ) { if ( ! $ this -> _isSetup ) { $ defaultConfig = array ( 'srcBasePath' => Yii :: getAlias ( '@webroot' ) , 'dstBasePath' => Yii :: $ app -> czaHelper -> folderOrganizer -> getEntityUploadPath ( true ) , 'dstUrlBase' => Yii :: $ app -> czaHelper -> folderOrganizer -> getEntityUploadPath ( )... | setup config on flying |
240,624 | function giveIdentity ( iIdentity $ identity ) { if ( $ this -> identity ) throw new \ Exception ( 'Identity is immutable.' ) ; $ defIdentity = $ this -> _newDefaultIdentity ( ) ; $ defIdentity -> import ( $ identity ) ; if ( ! $ defIdentity -> isFulfilled ( ) ) throw new \ InvalidArgumentException ( sprintf ( 'Identit... | Set Immutable Identity |
240,625 | final function issueException ( exAuthentication $ exception = null ) { $ callable = ( $ this -> issuer_exception ) ? $ this -> issuer_exception : $ this -> doIssueExceptionDefault ( ) ; return call_user_func ( $ callable , $ exception ) ; } | Issue To Handle Authentication Exception |
240,626 | function setIssuerException ( $ callable ) { if ( ! is_callable ( $ callable ) ) throw new \ InvalidArgumentException ( sprintf ( 'Issuer must be callable; given: (%s).' , \ Poirot \ Std \ flatten ( $ callable ) ) ) ; $ this -> issuer_exception = $ callable ; return $ this ; } | Set Exception Issuer |
240,627 | protected function writeCache ( $ class , $ content ) { $ date = date ( "Y-m-d h:i:s" ) ; $ content = <<<EOD<?php/** * Generated with RoutingCacheManager * * on {$date} */\$app = Slim\Slim::getInstance();{$content}EOD ; $ fileName = $ this -> cacheFile ( $ class ) ; file_put_contents ( $ fileName , $ content ) ; retur... | This method writes the cache content into cache file |
240,628 | function indexOfPattern ( $ pattern ) { self :: toUnicodeRegex ( $ pattern ) ; if ( ! preg_match ( $ pattern , $ this -> S , $ m , PREG_OFFSET_CAPTURE ) ) return false ; return $ m [ 0 ] [ 1 ] ; } | Searches for a pattern on a string and returns the index of the matched substring . |
240,629 | function search ( $ pattern , $ from = 0 , & $ match = null ) { self :: toUnicodeRegex ( $ pattern ) ; if ( preg_match ( $ pattern , $ this -> S , $ m , PREG_OFFSET_CAPTURE ) ) { list ( $ match , $ ofs ) = $ m [ 0 ] ; return $ ofs ; } return false ; } | Finds the position of the first occurrence of a pattern in the current string . |
240,630 | public function addError ( OperationError $ ex , bool $ stopPropagation = false ) { $ this -> lastError = $ ex ; if ( $ stopPropagation ) { $ this -> stopPropagation ( ) ; } } | Adds an OperationError to the operation events error list . |
240,631 | public function setResults ( $ results = null , bool $ stopPropagation = false ) { $ this -> result = $ results ; if ( $ stopPropagation ) { $ this -> stopPropagation ( ) ; } } | Sets the operations result . |
240,632 | public function query ( $ query , $ params = null , $ fetchResult = false ) { $ this -> checkConnection ( true ) ; $ this -> log ( 'Query: ' . $ query ) ; if ( ! empty ( $ params ) ) { $ this -> log ( 'Params: ' . print_r ( $ params , true ) ) ; } $ start = microtime ( true ) ; if ( empty ( $ params ) ) { $ res = $ thi... | Execute a query and return the results |
240,633 | protected function executeQuery ( $ query ) { $ res = @ odbc_exec ( $ this -> _lnk , $ query ) ; if ( ! $ res ) { $ error = odbc_errormsg ( $ this -> _lnk ) ; $ this -> log ( 'Query failed: ' . $ error ) ; throw new Exception ( 'Executing query failed ' . $ error , self :: QUERY_FAILED ) ; } return $ res ; } | Execute a query and returns an ODBC result identifier |
240,634 | protected function executePreparedStatement ( $ query , $ params ) { $ res = odbc_prepare ( $ this -> _lnk , $ query ) ; if ( ! $ res ) { $ error = odbc_errormsg ( $ this -> _lnk ) ; $ this -> log ( 'Prepare failed: ' . $ error ) ; throw new Exception ( 'Preparing query failed ' . $ error , self :: PREPARE_FAILED ) ; }... | Prepare a query execute it and return an ODBC result identifier |
240,635 | protected function checkConnection ( $ reconnect = false ) { if ( empty ( $ this -> _lnk ) ) { $ this -> log ( 'CheckConnection: link is not valid' ) ; if ( $ reconnect ) { $ this -> log ( 'CheckConnection: try to reconnect' ) ; $ this -> _lnk = @ odbc_connect ( 'Driver=' . VERTICA_DRIVER . ';Servername=' . VERTICA_SER... | Check if the connection failed and try to reconnect if asked |
240,636 | public static function decode ( $ cookie ) { $ params = ( array ) json_decode ( base64_decode ( $ cookie ) , true ) ; return new self ( ( string ) array_value ( $ params , 'user_email' ) , ( string ) array_value ( $ params , 'agent' ) , ( string ) array_value ( $ params , 'series' ) , ( string ) array_value ( $ params ... | Decodes an encoded remember me cookie string . |
240,637 | public function encode ( ) { $ json = json_encode ( [ 'user_email' => $ this -> email , 'agent' => $ this -> userAgent , 'series' => $ this -> series , 'token' => $ this -> token , ] ) ; return base64_encode ( $ json ) ; } | Encodes a remember me cookie . |
240,638 | public function isValid ( ) { if ( ! filter_var ( $ this -> email , FILTER_VALIDATE_EMAIL ) ) { return false ; } if ( empty ( $ this -> userAgent ) ) { return false ; } if ( empty ( $ this -> series ) ) { return false ; } if ( empty ( $ this -> token ) ) { return false ; } return true ; } | Checks if the cookie contains valid values . |
240,639 | public function verify ( Request $ req , AuthManager $ auth ) { if ( ! $ this -> isValid ( ) ) { return false ; } if ( $ this -> userAgent != $ req -> agent ( ) ) { return false ; } try { $ userClass = $ auth -> getUserClass ( ) ; $ user = $ userClass :: where ( 'email' , $ this -> email ) -> first ( ) ; } catch ( Mode... | Looks for a remembered user using this cookie from an incoming request . |
240,640 | public function persist ( UserInterface $ user ) { $ session = new PersistentSession ( ) ; $ session -> email = $ this -> email ; $ session -> series = $ this -> hash ( $ this -> series ) ; $ session -> token = $ this -> hash ( $ this -> token ) ; $ session -> user_id = $ user -> id ( ) ; $ session -> two_factor_verifi... | Persists this cookie to the database . |
240,641 | function destroy ( ) { $ seriesHash = $ this -> hash ( $ this -> series ) ; PersistentSession :: where ( 'email' , $ this -> email ) -> where ( 'series' , $ seriesHash ) -> delete ( ) ; } | Destroys the persisted cookie in the data store . |
240,642 | private function hash ( $ token ) { $ app = Application :: getDefault ( ) ; $ salt = $ app [ 'config' ] -> get ( 'app.salt' ) ; return hash_hmac ( 'sha512' , $ token , $ salt ) ; } | Hashes a token . |
240,643 | protected function getFilesListing ( $ path , array $ params ) { $ files = $ this -> getFiles ( $ path , $ params ) ; return $ this -> prepareFiles ( $ files ) ; } | Returns an array of scanned and prepared files |
240,644 | protected function prepareFiles ( array $ files ) { $ prepared = array ( ) ; foreach ( $ files as $ file ) { $ type = $ file -> getType ( ) ; $ path = $ file -> getRealPath ( ) ; $ relative_path = gplcart_file_relative ( $ path ) ; $ item = array ( 'info' => $ file , 'type' => $ type , 'path' => $ relative_path , 'owne... | Prepares an array of scanned files |
240,645 | protected function renderIcon ( array $ item ) { static $ rendered = array ( ) ; if ( isset ( $ rendered [ $ item [ 'extension' ] ] ) ) { return $ rendered [ $ item [ 'extension' ] ] ; } $ template = "file_manager|icons/ext/{$item['extension']}" ; if ( $ item [ 'type' ] === 'dir' ) { $ template = 'file_manager|icons/di... | Returns a rendered icon for the given file extension and type |
240,646 | protected function isKnownFeed ( ) { if ( empty ( config ( "{$this->configBase}.feeds.{$this->feedName}" ) ) ) { $ this -> warningCount ++ ; Log :: warning ( "The feed referred as '{$this->feedName}' is not configured in the collector " . config ( "{$this->configBase}.collector.name" ) . ' therefore skipping processing... | Check if the feed specified is known in the collector config . |
240,647 | public function transmute ( $ inFilename , Specification $ targetFormat , $ outFilename ) { $ extractedFile = $ this -> extractor -> extract ( $ inFilename , $ targetFormat ) ; if ( ! $ extractedFile ) { return null ; } $ this -> converter -> convert ( $ extractedFile , $ targetFormat , $ outFilename ) ; return $ outFi... | Transmute file to target format |
240,648 | public function add ( $ attribute , $ value = array ( ) ) { if ( is_array ( $ attribute ) ) { foreach ( $ attribute as $ k => $ v ) { $ this -> add ( $ k , $ v ) ; } } else { if ( $ attribute instanceof \ Thin \ Html \ Attributes ) { $ this -> add ( $ attribute -> getArray ( ) ) ; } else { $ attribute = strval ( $ attr... | Add an attribute or an array thereof . If the attribute already exists the specified values will be added to it without overwriting the previous ones . Duplicate values are removed . |
240,649 | public function set ( $ attribute , $ value = array ( ) ) { if ( is_array ( $ attribute ) ) { $ this -> attributes = array ( ) ; foreach ( $ attribute as $ k => $ v ) { $ this -> set ( $ k , $ v ) ; } } else { if ( $ attribute instanceof \ Thin \ Html \ Attributes ) { $ this -> attributes = $ attribute -> getArray ( ) ... | Set the value or values of an attribute or an array thereof . Already existent attributes are overwritten . |
240,650 | public function remove ( $ attribute , $ value = null ) { $ attribute = strval ( $ attribute ) ; if ( \ Thin \ Arrays :: exists ( $ attribute , $ this -> attributes ) ) { if ( null === $ value ) { unset ( $ this -> attributes [ $ attribute ] ) ; } else { $ value = strval ( $ value ) ; foreach ( $ this -> attributes [ $... | Remove an attribute or a value |
240,651 | public function getArray ( $ attribute = null ) { if ( null === $ attribute ) { return $ this -> attributes ; } else { $ attribute = strval ( $ attribute ) ; if ( ake ( $ attribute , $ this -> attributes ) ) { return $ this -> attributes [ $ attribute ] ; } } return null ; } | Get the entire attributes array or the array of values for a single attribute . |
240,652 | public function getHtml ( $ attribute = null ) { if ( null !== $ attribute ) { $ attribute = strval ( $ attribute ) ; if ( \ Thin \ Arrays :: exists ( $ attribute , $ this -> attributes ) ) { return $ attribute . '="' . implode ( ' ' , $ this -> attributes [ $ attribute ] ) . '"' ; } } else { $ return = array ( ) ; for... | Generate the HTML code for the attributes |
240,653 | public function exists ( $ attribute , $ value = null ) { $ attribute = strval ( $ attribute ) ; if ( \ Thin \ Arrays :: exists ( $ attribute , $ this -> attributes ) ) { if ( null === $ value || in_array ( strval ( $ value ) , $ this -> attributes [ $ attribute ] ) ) { return true ; } } return false ; } | Check whether a given attribute or attribute value exists |
240,654 | public static function getStatementType ( String $ query ) : Int { $ type = 0 ; if ( preg_match ( "/^SELECT|select|Select([^ ]+)/" , $ query ) ) { $ type = 1 ; } if ( preg_match ( "/^INSERT([^ ]+)/" , $ query ) ) { $ type = 2 ; } if ( preg_match ( "/^UPDATE([^ ]+)/" , $ query ) ) { $ type = 3 ; } if ( preg_match ( "/^D... | This method gets and returns the statement type . |
240,655 | public function actionPhrase ( ) { $ this -> stdout ( 'phraseLiveTime: ' . \ Yii :: $ app -> cmsSearch -> phraseLiveTime . "\n" ) ; if ( \ Yii :: $ app -> cmsSearch -> phraseLiveTime ) { $ deleted = CmsSearchPhrase :: deleteAll ( [ '<=' , 'created_at' , \ Yii :: $ app -> formatter -> asTimestamp ( time ( ) ) - ( int ) ... | Remove old searches |
240,656 | private function write_to ( $ file , $ data ) { $ handler = fopen ( $ file , "w" ) ; fwrite ( $ handler , $ data ) ; fclose ( $ handler ) ; } | Creates the handler and writes the files . |
240,657 | public function write ( $ path = '' , $ file = '' , $ content = '' ) { $ the_path = Application :: config ( ) -> public_folder ( ) . '/' . $ path ; @ mkdir ( $ the_path , 0755 , true ) ; $ this -> write_to ( $ the_path . '/' . $ file , $ content ) ; } | Write the file . |
240,658 | protected function _deserializeResponse ( $ responseData ) { try { $ this -> getResponseBody ( ) -> deserialize ( $ responseData ) ; } catch ( Radial_RiskService_Sdk_Exception_Invalid_Payload_Exception $ e ) { $ logMessage = sprintf ( '[%s] Error Payload Response Body: %s' , __CLASS__ , $ this -> cleanAuthXml ( $ respo... | Deserialized the response xml into response payload if an exception is thrown catch it and set the error payload and deserialized the response xml into it . |
240,659 | protected function _sendRequest ( ) { $ this -> _lastRequestsResponse = null ; $ httpMethod = strtolower ( $ this -> _config -> getHttpMethod ( ) ) ; if ( ! method_exists ( $ this , $ httpMethod ) ) { throw Mage :: exception ( 'Radial_RiskService_Sdk_Exception_Unsupported_Http_Action' , sprintf ( 'HTTP action %s not su... | Send get or post CURL request to the API URI . |
240,660 | protected function _post ( ) { $ requestXml = $ this -> getRequestBody ( ) -> serialize ( ) ; if ( $ this -> _helperConfig -> isDebugMode ( ) ) { $ logMessage = sprintf ( '[%s] Request Body: %s' , __CLASS__ , $ this -> cleanAuthXml ( $ requestXml ) ) ; Mage :: log ( $ logMessage , Zend_Log :: DEBUG ) ; } $ xml = simple... | Send post CURL request . |
240,661 | protected function _get ( ) { $ this -> _lastRequestsResponse = Requests :: post ( $ this -> _config -> getEndpoint ( ) , $ this -> _buildHeader ( ) ) ; return $ this -> _lastRequestsResponse -> success ; } | Send get CURL request . |
240,662 | public function cleanAuthXml ( $ xml ) { $ xml = preg_replace ( '#(\<(?:Encrypted)?CardSecurityCode\>).*(\</(?:Encrypted)?CardSecurityCode\>)#' , '$1***$2' , $ xml ) ; $ xml = preg_replace ( '#(\<(?:Encrypted)?PaymentAccountUniqueId.*?\>).*(\</(?:Encrypted)?PaymentAccountUniqueId\>)#' , '$1***$2' , $ xml ) ; $ xml = pr... | Scrub the auth request XML message of any sensitive data - CVV CC number . |
240,663 | public function set ( array $ methods , array $ args ) : RouterInterface { list ( $ pattern , $ callable ) = $ args ; $ route = new Route ( $ methods , $ pattern , $ callable ) ; $ this -> setRoute ( $ route ) ; return $ this ; } | Abstraction of setter |
240,664 | public function checkMethods ( array $ methods ) : array { return array_map ( function ( $ method ) { $ method = strtolower ( $ method ) ; if ( ! \ in_array ( $ method , self :: METHODS , false ) ) { throw new Exception ( "Method \"$method\" is not in allowed list [" . implode ( ',' , self :: METHODS ) . ']' ) ; } retu... | Check if passed methods in allowed list |
240,665 | public function map ( array $ methods , string $ pattern , $ callable ) : MethodsInterface { $ methods = $ this -> checkMethods ( $ methods ) ; $ this -> set ( $ methods , [ $ pattern , $ callable ] ) ; return $ this ; } | Callable must be only selected methods |
240,666 | public function any ( string $ pattern , $ callable ) : MethodsInterface { $ this -> set ( self :: METHODS , [ $ pattern , $ callable ] ) ; return $ this ; } | Any method should be callable |
240,667 | public function setRoute ( RouteInterface $ route ) : RouterInterface { $ regexp = $ route -> getRegexp ( ) ; $ this -> _routes [ $ regexp ] = $ route ; return $ this ; } | Add route into the array of routes |
240,668 | private function checkMatches ( string $ uri , string $ method ) : array { return array_map ( function ( $ regexp , $ route ) use ( $ uri , $ method ) { $ match = preg_match_all ( $ regexp , $ uri , $ matches ) ; if ( $ match && $ route -> checkMethod ( $ method ) ) { $ route -> setVariables ( $ matches ) ; return $ ro... | Find route object by URL nad method |
240,669 | private function getMatches ( ) : array { $ uri = $ this -> getRequest ( ) -> getUri ( ) -> getPath ( ) ; $ method = $ this -> getRequest ( ) -> getMethod ( ) ; $ method = strtolower ( $ method ) ; return $ this -> checkMatches ( $ uri , $ method ) ; } | Find optimal route from array of routes by regexp and uri |
240,670 | public function getRoute ( ) : RouteInterface { $ matches = $ this -> getMatches ( ) ; $ matches = array_values ( array_filter ( $ matches ) ) ; $ result = ! empty ( $ matches ) ? $ matches [ 0 ] : $ this -> getError ( ) ; return $ result ; } | Parse URI by Regexp from routes and return single route |
240,671 | public function getRoutes ( bool $ keys = false ) : array { return $ keys ? array_keys ( $ this -> _routes ) : $ this -> _routes ; } | Get all available routes |
240,672 | public function get ( string $ index ) : string { if ( ! $ this -> isValid ( $ index ) ) { throw new \ InvalidArgumentException ( 'The specified value does not exist' ) ; } return $ this -> map [ $ index ] ; } | Retrieve a value |
240,673 | public function addValue ( string $ key , string $ value ) : void { $ this -> map [ $ key ] = $ value ; } | Add a new value to the map |
240,674 | public function deleteValue ( string $ key ) : void { if ( isset ( $ this -> map [ $ key ] ) ) { unset ( $ this -> map [ $ key ] ) ; } } | Delete a value from the map based on the key |
240,675 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ evm = $ serviceLocator -> get ( 'EventManager' ) ; $ config = $ serviceLocator -> get ( 'Config' ) ; $ config = empty ( $ config [ 'valu_so' ] ) ? [ ] : $ config [ 'valu_so' ] ; $ cacheConfig = isset ( $ config [ 'cache' ] ) ? $ config [ 'ca... | Create a ServiceBroker |
240,676 | public function create ( $ filename , $ content ) { $ filename = str :: path ( $ filename ) ; $ this -> createDirectory ( dirname ( $ filename ) ) ; return file_put_contents ( $ filename , $ content ) ; } | To create file |
240,677 | public function delete ( $ filename ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return @ unlink ( $ filename ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; } | To delete file |
240,678 | public function update ( $ filename , $ content ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return $ this -> create ( $ filename , $ content ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; } | To update file |
240,679 | public function get ( $ filename ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return file_get_contents ( $ filename ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; } | To get file content |
240,680 | public function append ( $ filename , $ content ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return file_put_contents ( $ filename , $ content , FILE_APPEND ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; } | To append file |
240,681 | public function size ( $ filename ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return filesize ( $ filename ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; } | To get a filesize in byte |
240,682 | public function files ( $ directoryName ) { if ( ! $ this -> isDir ( $ directoryName ) ) { throw new FileNotFoundException ( 'Directory not found in the path [ ' . $ directoryName . ' ].' ) ; } $ files = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ directoryName , RecursiveDirectoryIterator :: SKI... | To get all files in a directory |
240,683 | public function directories ( $ directoryName ) { if ( ! $ this -> isDir ( $ directoryName ) ) { throw new FileNotFoundException ( 'Directory not found in the path [ ' . $ directoryName . ' ].' ) ; } $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ directoryName , RecursiveDirectoryIterat... | To get all directories in a directory |
240,684 | public function cleanDirectory ( $ directoryName , $ deleteRootDirectory = false ) { if ( is_dir ( $ directoryName ) ) { $ files = glob ( $ directoryName . '/*' , GLOB_NOSORT ) ; foreach ( $ files as $ file ) { $ this -> cleanDirectory ( $ file , true ) ; } if ( file_exists ( $ directoryName ) && ( $ deleteRootDirector... | To clean a directory |
240,685 | public function addElement ( $ tag , array $ attributes = [ ] ) { if ( $ tag instanceof self ) { $ htmlTag = $ tag ; $ htmlTag -> top = $ this -> top ; $ htmlTag -> attrs ( $ attributes ) ; $ this -> elements -> add ( $ htmlTag ) ; return $ htmlTag ; } return self :: make ( $ tag , $ attributes , $ this -> hasParent ( ... | Add element at an existing Markup |
240,686 | public function getFirst ( ) { $ element = null ; if ( $ this -> hasParent ( ) and $ this -> parent -> hasElements ( ) ) { $ element = $ this -> parent -> elements [ 0 ] ; } return $ element ; } | Return first child of parent of current object |
240,687 | protected function getMountPoint ( $ path ) { while ( $ path !== '' ) { if ( isset ( $ this -> filesystems [ $ path ] ) ) { return $ path ; } $ path = substr ( $ path , 0 , strrpos ( $ path , '/' ) ) ; } return '/' ; } | Find mount point of the path |
240,688 | public static function make ( $ value , $ rounds = 8 ) { $ work = str_pad ( $ rounds , 2 , '0' , STR_PAD_LEFT ) ; if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ salt = openssl_random_pseudo_bytes ( 16 ) ; } else { $ salt = Inflector :: random ( 40 ) ; } $ salt = substr ( strtr ( base64_encode ( $ salt ) ,... | Hash a password using the Bcrypt hashing scheme . |
240,689 | public static function registerSystemErrors ( Slim $ app ) : void { $ c = $ app -> getContainer ( ) ; $ c [ 'errorHandler' ] = function ( $ c ) { return function ( Request $ request , Response $ response , \ Exception $ exception ) use ( $ c ) : Response { $ response = $ c [ 'response' ] ; return $ response -> withStat... | Injects a custom error handling into the Slim - framework |
240,690 | public static function make ( TagInterface $ tag ) { if ( $ tag -> getType ( ) === '' and $ tag -> getText ( ) !== '' ) { return $ tag -> getText ( ) ; } return self :: isAutoClosed ( $ tag -> getType ( ) ) ? self :: open ( $ tag , true ) : self :: open ( $ tag ) . $ tag -> getText ( ) . $ tag -> renderElements ( ) . s... | Render a Tag and its elements |
240,691 | private static function open ( TagInterface $ tag , $ autoClosed = false ) { $ output = '<' . $ tag -> getType ( ) ; if ( $ tag -> hasAttributes ( ) ) { $ output .= ' ' . $ tag -> renderAttributes ( ) ; } $ output .= ( $ autoClosed ? '/>' : '>' ) ; return $ output ; } | Render open Tag |
240,692 | public function bindParam ( $ placeholder , & $ var , $ type = null ) { $ this -> param_list [ $ placeholder ] = & $ var ; if ( ! empty ( $ type ) && in_array ( $ type , $ this -> _type_list ) ) { $ this -> type_list [ $ placeholder ] = & $ type ; } return true ; } | binds a parameter |
240,693 | public function fetchAll ( $ type = null ) { try { if ( $ this -> res === false ) { throw new DatabaseException ( __METHOD__ . " No ressource has been given" , MySQL :: NO_RESSOURCE , MySQL :: SEVERITY_DEBUG , __FILE__ , __LINE__ ) ; } switch ( $ type ) { case MySQL :: FETCH_ASSOC : return $ this -> _db -> fetch_assoc_... | fetch all option |
240,694 | public function hasTag ( $ tag ) { foreach ( $ this -> lines as $ line ) { if ( strpos ( $ line , '@' . $ tag ) === 0 ) { return TRUE ; } } return FALSE ; } | Check if a tag is set in the comment |
240,695 | public function getTags ( $ tag ) { $ tags = array ( ) ; foreach ( $ this -> lines as $ line ) { if ( strpos ( $ line , '@' . $ tag ) === 0 ) { $ tags [ ] = trim ( substr ( $ line , strlen ( '@' . $ tag ) ) ) ; } } return $ tags ; } | Return array of matching tags |
240,696 | public function getLongDescription ( ) { $ comment = '' ; foreach ( $ this -> lines as $ key => $ line ) { if ( $ key == 0 || ( $ line && $ line [ 0 ] == '@' ) ) { continue ; } if ( $ comment ) { $ comment .= "\n" ; } $ comment .= $ line ; } return $ comment ; } | Return long description This is every other line of a comment besides the first line and any tags |
240,697 | public static function starComment ( $ strComment , $ intTabs = 0 ) { $ strReturn = '' ; $ arrComment = explode ( "\n" , $ strComment ) ; $ intFirstSlash = strpos ( $ arrComment [ 0 ] , '/' ) ; $ strPrefix = ( $ intFirstSlash ) ? substr ( $ arrComment [ 0 ] , 0 , $ intFirstSlash ) : NULL ; $ strComment = self :: cleanC... | Return a stared comment |
240,698 | public static function lineComment ( $ strComment , $ intTabs = 0 ) { $ strReturn = '' ; $ arrComment = explode ( "\n" , $ strComment ) ; $ intFirstSlash = strpos ( $ arrComment [ 0 ] , '/' ) ; $ strPrefix = ( $ intFirstSlash ) ? substr ( $ arrComment [ 0 ] , 0 , $ intFirstSlash ) : NULL ; $ strComment = self :: cleanC... | Return a lined comment |
240,699 | public function getCommits ( ) { $ log = $ this -> execute ( "git log --no-merges --format='changeset: %H%nuser: %aN <%aE>%ndate: %ad%nsummary: %s%n' " . $ this -> repository_path ) ; $ this -> repository_type = 'git' ; return $ this -> parseLog ( $ log ) ; } | Get the list of Git commits for the repository as a structured array |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.