idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
59,600 | public function response ( ServerRequestInterface $ request , PayloadInterface $ payload ) : ResponseInterface { $ responder = $ this -> container -> get ( $ this -> id ) ; if ( $ responder instanceof ResponderInterface ) { return $ responder -> response ( $ request , $ payload ) ; } throw new ContainedResponderTypeExc... | Get the responder from the container then proxy its response method . |
59,601 | public function clear ( $ type = null ) { if ( false === $ this -> mf -> hasCache ( ) ) { return [ ] ; } return $ this -> doClear ( $ this -> getTypes ( $ type ) ) ; } | Clears metadata objects from the cache . |
59,602 | public function warm ( $ type = null ) { if ( false === $ this -> mf -> hasCache ( ) ) { return [ ] ; } return $ this -> doWarm ( $ this -> getTypes ( $ type ) ) ; } | Warms up metadata objects into the cache . |
59,603 | private function doClear ( array $ types ) { $ cleared = [ ] ; $ this -> mf -> enableCache ( false ) ; foreach ( $ types as $ type ) { $ metadata = $ this -> mf -> getMetadataForType ( $ type ) ; $ this -> mf -> getCache ( ) -> evictMetadataFromCache ( $ metadata ) ; $ cleared [ ] = $ type ; } $ this -> mf -> enableCac... | Clears metadata objects for the provided model types . |
59,604 | private function doWarm ( array $ types ) { $ warmed = [ ] ; $ this -> doClear ( $ types ) ; foreach ( $ types as $ type ) { $ this -> mf -> getMetadataForType ( $ type ) ; $ warmed [ ] = $ type ; } return $ warmed ; } | Warms up the metadata objects for the provided model types . |
59,605 | public function send ( $ email , $ name = null , $ subject , $ body , $ attachment = null , $ bcc = null ) { $ this -> phpMailer -> isSMTP ( ) ; $ this -> phpMailer -> Host = $ this -> app -> config -> getMail ( 'host' ) ; $ this -> phpMailer -> SMTPAuth = true ; $ this -> phpMailer -> Username = $ this -> app -> confi... | To send an email |
59,606 | protected function logEmail ( $ body ) { if ( ! $ this -> filesystem -> exists ( $ this -> getLogDirectory ( ) ) ) { $ this -> filesystem -> createDirectory ( $ this -> getLogDirectory ( ) ) ; } return $ this -> filesystem -> create ( $ this -> logFileName , $ body ) ; } | Generate Email Log File |
59,607 | public function createClassTemplate ( String $ templateName , String $ filename , $ savePath = null , Array $ templateTags ) { $ template = file_get_contents ( __DIR__ . '/templates/' . $ templateName ) ; foreach ( $ templateTags as $ key => $ tag ) { if ( ! preg_match_all ( '/' . $ key . '/' , $ template ) ) { throw n... | Builds a class template . |
59,608 | public function getLogFile ( ) { if ( $ this -> _fp === null ) { $ this -> LOG_DIR = ROOT . DS . 'app' . DS . 'logs' ; $ filename = $ this -> LOG_DIR . DS . date ( "Y-m-d" ) ; $ this -> _fp = fopen ( $ filename , 'a' ) ; if ( $ this -> _fp === false ) { throw new LoggerException ( 'Cannot open log file: ' . $ filename ... | Opens log file only if it s not already open |
59,609 | protected function flush ( ) { echo "\nFlushing directories... " ; foreach ( $ this -> flushPaths as $ dir ) { $ path = $ this -> basePath . '/' . $ dir ; if ( file_exists ( $ path ) ) { $ this -> flushDirectory ( $ path ) ; } $ this -> ensureDirectory ( $ path ) ; } echo "done\n" ; } | Flushes directories . |
59,610 | protected function flushDirectory ( $ path , $ delete = false ) { if ( is_dir ( $ path ) ) { $ entries = scandir ( $ path ) ; foreach ( $ entries as $ entry ) { $ exclude = array_merge ( array ( '.' , '..' ) , $ this -> exclude ) ; if ( in_array ( $ entry , $ exclude ) ) { continue ; } $ entryPath = $ path . '/' . $ en... | Flushes a directory recursively . |
59,611 | protected function mergeMeta ( array $ meta , array $ sourceMeta ) : array { $ properties = $ meta [ 'properties' ] ?? [ ] ; $ sourceProperties = $ sourceMeta [ 'properties' ] ?? [ ] ; foreach ( $ sourceProperties as $ name => $ data ) { $ properties [ $ name ] = array_merge ( $ properties [ $ name ] ?? [ ] , $ data ) ... | Merge meta data |
59,612 | public function page ( Request $ request , Application $ app , Paginator $ paginator ) { return array_merge ( [ 'pages' => count ( $ paginator ) ] , $ this -> extractViewParameters ( $ request , [ 'app' , 'paginator' ] ) ) ; } | Paginated list of contents |
59,613 | protected function extractViewParameters ( Request $ request , array $ exclude = [ ] ) { $ parameters = [ ] ; foreach ( $ request -> attributes as $ key => $ value ) { if ( strpos ( $ key , '_' ) !== 0 && ! in_array ( $ key , $ exclude ) ) { $ parameters [ $ key ] = $ value ; } } return $ parameters ; } | Extract view parameters from Request attributes |
59,614 | public function translate ( $ object ) { $ commandBaseNamespace = app ( ) -> getNamespace ( ) . "Commands" ; $ handlerBaseNamespace = app ( ) -> getNamespace ( ) . "Handlers" ; $ reflectionObject = new ReflectionClass ( $ object ) ; $ commandNamespace = $ this -> getCommandNamespace ( $ commandBaseNamespace , $ reflect... | To translate command to command handler |
59,615 | public function find ( $ item = null , $ array = null ) { if ( is_null ( $ item ) ) return null ; if ( strpos ( $ item , '.' ) ) { $ arr = explode ( '.' , $ item ) ; if ( count ( $ arr ) > 2 ) { $ itemToSearch = join ( '.' , array_slice ( $ arr , 1 ) ) ; } else { $ itemToSearch = $ arr [ 1 ] ; } return $ this -> findIt... | Recursively finds an item from the settings array |
59,616 | private function getLabelFor ( $ property ) { switch ( $ property ) { case 'nid' : return t ( "Node ID." ) ; case 'vid' : return t ( "Revision ID." ) ; case 'type' : return t ( "Type" ) ; case 'language' : return t ( "Language" ) ; case 'label' : return t ( "Label" ) ; case 'title' : return t ( "Title" ) ; case 'uid' :... | Attempt to guess the property description knowing that Drupalisms are strong and a lot of people will always use the same colum names |
59,617 | private function schemaApiTypeToPropertyInfoType ( $ type ) { switch ( $ type ) { case 'serial' : case 'int' : return new Type ( Type :: BUILTIN_TYPE_INT , true ) ; case 'float' : case 'numeric' : return new Type ( Type :: BUILTIN_TYPE_FLOAT , true ) ; case 'varchar' : case 'text' : case 'blob' : return new Type ( Type... | Convert schema API type to property info type |
59,618 | private function getEntityTypeInfo ( $ class ) { $ entityType = $ this -> getEntityType ( $ class ) ; if ( ! $ entityType ) { return [ null , null ] ; } $ info = entity_get_info ( $ entityType ) ; if ( ! $ info ) { return [ null , null ] ; } return [ $ entityType , $ info ] ; } | Get entity type info for the given class |
59,619 | private function findFieldInstances ( $ entityType , $ entityInfo ) { $ ret = [ ] ; foreach ( field_info_instances ( $ entityType ) as $ fields ) { foreach ( $ fields as $ name => $ instance ) { if ( isset ( $ ret [ $ name ] ) ) { continue ; } $ ret [ $ name ] = $ instance ; } } return $ ret ; } | Guess the while field instances for the given entity type |
59,620 | private function findFieldInstanceFor ( $ entityType , $ entityInfo , $ property ) { $ instances = $ this -> findFieldInstances ( $ entityType , $ entityInfo ) ; if ( isset ( $ instances [ $ property ] ) ) { return $ instances [ $ property ] ; } } | Guess the field instance for a single property of the given entity type |
59,621 | public function camelize ( $ input ) { $ input = trim ( $ input ) ; if ( empty ( $ input ) ) { throw new \ Exception ( "Can not camelize an empty string." ) ; } $ output = '' ; $ capitalizeNext = $ this -> shouldCapitalizeFirstLetter ; for ( $ i = 0 ; $ i < mb_strlen ( $ input ) ; ++ $ i ) { $ character = mb_substr ( $... | Camel Case a String |
59,622 | public function equals ( Money $ money ) { return $ this -> isSameCurrency ( $ money ) && $ this -> cents == $ money -> cents ; } | Check the equality of two Money objects . First check the currency and then check the value . |
59,623 | public function add ( Money $ money ) { if ( $ this -> isSameCurrency ( $ money ) ) { return Money :: init ( $ this -> cents + $ money -> cents , $ this -> currency -> getIsoCode ( ) ) ; } throw new InvalidCurrencyException ( "You can't add two Money objects with different currencies" ) ; } | Add two the value of two Money objects and return a new Money object . |
59,624 | public function multiply ( $ number ) { return Money :: init ( ( int ) round ( $ this -> cents * $ number , 0 , PHP_ROUND_HALF_EVEN ) , $ this -> currency -> getIsoCode ( ) ) ; } | Multiply two Money objects together and return a new Money object |
59,625 | public function addVisitor ( VisitorInterface $ visitor , $ priority = 0 ) { $ this -> sortedVisitors = null ; $ this -> visitors [ spl_object_hash ( $ visitor ) ] = array ( 'priority' => $ priority , 'visitor' => $ visitor ) ; return $ this ; } | Add detection visitor |
59,626 | public static function createDefault ( DictionaryInterface $ dictionary = null ) { $ detector = new static ( ) ; $ dataDirectory = realpath ( __DIR__ . '/../../../data' ) ; $ alphabetLoader = new AlphabetLoader ( ) ; $ sectionLoader = new SectionLoader ( ) ; $ sections = $ sectionLoader -> load ( $ dataDirectory . '/se... | Create default detector |
59,627 | public function setDefaultValue ( $ value ) : FormElement { if ( is_array ( $ value ) ) { $ value = implode ( ',' , $ value ) ; } parent :: setDefaultValue ( $ value ) ; return $ this ; } | Sets the default or database value for the element . Overridden to convert arrays to strings . |
59,628 | public function setUserValue ( string $ value ) : FormElement { if ( is_array ( $ value ) ) { $ value = implode ( ',' , $ value ) ; } parent :: setUserValue ( $ value ) ; return $ this ; } | Sets a user value to be validated . Overridden to convert arrays to strings . |
59,629 | public function validate ( ) : void { if ( null === $ this -> is_valid ) { if ( null === $ this -> user_value && null !== $ this -> default_value ) { $ this -> is_valid = true ; } elseif ( null != $ this -> validator && false != $ this -> validator ) { $ validator = $ this -> validator ; $ valids = array ( ) ; $ all_va... | Validates the user value according to the validator defined for this element . |
59,630 | public function p2br ( $ data ) { $ data = preg_replace ( '#<p[^>]*?>#' , '' , $ data ) ; $ data = preg_replace ( '#</p>$#' , '' , $ data ) ; $ data = str_replace ( '</p>' , '<br /><br />' , $ data ) ; return $ data ; } | Replaces paragraph formatting with double linebreaks . |
59,631 | public function paragraphs_slice ( $ text , $ offset = 0 , $ length = null ) { $ result = array ( ) ; preg_match_all ( '#<p[^>]*>(.*?)</p>#' , $ text , $ result ) ; if ( $ length === null ) { $ length = count ( $ result [ 0 ] ) - $ offset ; } return array_slice ( $ result [ 0 ] , $ offset , $ length ) ; } | Extracts paragraphs from a string . |
59,632 | public function regex_replace ( $ subject , $ pattern , $ replacement , $ limit = - 1 ) { return preg_replace ( $ pattern , $ replacement , $ subject , $ limit ) ; } | Performs a regular expression search and replace . |
59,633 | protected function getActionsColumn ( $ canAddLanguage ) { return function ( $ row ) use ( $ canAddLanguage ) { $ btns = [ ] ; $ html = app ( 'html' ) ; if ( $ canAddLanguage && ! $ row -> is_default ) { $ btns [ ] = $ html -> create ( 'li' , $ html -> link ( handles ( "antares::translations/languages/delete/" . $ row ... | Actions column for datatable |
59,634 | protected function persistResource ( ResourceEvent $ event ) { $ resource = $ event -> getResource ( ) ; try { $ this -> manager -> persist ( $ resource ) ; $ this -> manager -> flush ( ) ; } catch ( DBALException $ e ) { if ( $ this -> debug ) { throw $ e ; } $ event -> addMessage ( new ResourceMessage ( 'ekyna_admin.... | Persists a resource . |
59,635 | public static function delete ( $ path ) { if ( ! is_readable ( $ path ) ) { return false ; } if ( ! is_dir ( $ path ) ) { unlink ( $ path ) ; return true ; } foreach ( scandir ( $ path ) as $ file ) { if ( $ file === '.' || $ file === '..' ) { continue ; } $ file = $ path . '/' . $ file ; if ( is_dir ( $ file ) ) { se... | Deletes a file or directory recursively . |
59,636 | public function setParameter ( String $ key , $ value , Bool $ override = false ) { if ( $ this -> getParameter ( $ key ) ) { $ defValue = $ this -> getParameter ( $ key ) ; $ this -> parameters [ $ key ] = [ $ defValue ] ; $ this -> parameters [ $ key ] [ ] = $ value ; return ; } $ this -> parameters [ $ key ] = $ val... | Sets a parameter key and value . |
59,637 | public function getType ( $ parameter = '' ) { $ parameterType = null ; switch ( gettype ( $ parameter ) ) { case 'string' : $ parameterType = 's' ; break ; case 'numeric' : case 'integer' : $ parameterType = 'i' ; break ; case 'double' : $ parameterType = 'd' ; break ; default : $ parameterType = null ; break ; } retu... | Return a parameter type . |
59,638 | public static function makeBinding ( $ parameter , $ value , $ data_type = PDO :: PARAM_STR ) { $ binding = new Binding ( new static , $ parameter , $ value , $ data_type ) ; return $ binding ; } | Creates a new instance of Stratedge \ Wye \ Binding . |
59,639 | public static function executeStatement ( PDOStatement $ statement , array $ params = null ) { static :: addStatement ( $ statement ) ; if ( is_array ( $ params ) ) { $ statement -> getBindings ( ) -> hydrateFromArray ( $ params ) ; } $ result = static :: getOrCreateResultAt ( static :: numQueries ( ) ) ; $ statement -... | Records a simulation of a query execution . |
59,640 | public static function beginTransaction ( ) { if ( static :: inTransaction ( ) ) { throw new PDOException ( ) ; } static :: inTransaction ( true ) ; $ transaction = static :: makeTransaction ( static :: countTransactions ( ) ) ; static :: addTransaction ( $ transaction ) ; } | Places Wye into transaction mode and increments number of transactions . If a transaction is already open throws a PDOException |
59,641 | public static function getOrCreateResultAt ( $ index = 0 ) { $ results = static :: getResultAt ( $ index ) ; if ( is_null ( $ results ) ) { $ results = static :: makeResult ( ) -> attachAtIndex ( $ index ) ; } return $ results ; } | Retrieve a result at a specific index . If no result is found a new blank result will be generated stored at the index and returned . |
59,642 | public static function addResultAtIndex ( Result $ result , $ index ) { $ results = static :: getResults ( ) ; $ results [ $ index ] = $ result ; static :: setResults ( $ results ) ; } | Attach a result at a specific index . If a result already exists the current one will be replaced with the new one . |
59,643 | public function createPath ( $ base , $ path ) { if ( ! is_dir ( $ base ) || ! is_writable ( $ base ) ) { return false ; } if ( empty ( $ path ) ) { return false ; } $ pieces = explode ( self :: DS , $ path ) ; $ dir = $ base ; foreach ( $ pieces as $ directory ) { if ( empty ( $ directory ) ) { continue ; } $ singlePa... | Create a new path on top of a base directory |
59,644 | public function recursivelyDeleteFromDirectory ( $ baseDirectory ) { if ( ! is_dir ( $ baseDirectory ) ) { return ; } $ iterator = new \ RecursiveDirectoryIterator ( $ baseDirectory ) ; $ files = new \ RecursiveIteratorIterator ( $ iterator , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ files as $ file ) ... | Recursively delete files and folders when given a base path |
59,645 | public function equals ( ActivityFeedItem $ otherItem ) : bool { return $ this -> getTime ( ) -> format ( "Ymd" ) == $ otherItem -> getTime ( ) -> format ( "Ymd" ) && $ this -> getTitle ( ) == $ otherItem -> getTitle ( ) && $ this -> getDescription ( ) == $ otherItem -> getDescription ( ) ; } | Compares this feed item to another . Only the date part of the time is compared because adventurer s log feeds only contain accurate date parts . |
59,646 | public function getIdentity ( $ spec = null , $ default = null ) { if ( $ spec !== null ) { return isset ( $ this -> identity [ $ spec ] ) ? $ this -> identity [ $ spec ] : $ default ; } else { return $ this -> identity ; } } | Retrieve identity or identity spec |
59,647 | public static function normalizeHeaderName ( $ headerName , $ stripX = false ) { if ( is_array ( $ headerName ) ) { array_walk ( $ headerName , function ( & $ name ) use ( $ stripX ) { $ name = self :: normalizeHeaderName ( $ name , $ stripX ) ; } ) ; } else { $ headerName = trim ( ( string ) $ headerName , " \t:" ) ; ... | Normalizes a header name |
59,648 | public static function appendUrlQuery ( $ url , $ query ) { if ( is_array ( $ query ) ) { $ query = http_build_query ( $ query ) ; } $ query = ltrim ( $ query , "?&" ) ; $ joiner = strpos ( $ url , "?" ) === false ? "?" : "&" ; return "{$url}{$joiner}{$query}" ; } | Appends the query string to the url |
59,649 | public function render ( $ template , $ options = array ( ) ) { $ pre_render = view ( $ template , $ options ) ; $ md = new \ Parsedown ( ) ; return $ md -> text ( $ pre_render ) ; } | Render the template with options . |
59,650 | public function execUp ( string $ name ) : void { DB :: connection ( 'default' ) -> table ( 'migrations' ) -> insert ( [ 'name' => $ name ] ) ; $ this -> up ( ) ; } | Kicks of the Migration - Up Process |
59,651 | public function execDown ( string $ name ) : void { $ this -> down ( ) ; DB :: connection ( 'default' ) -> table ( 'migrations' ) -> where ( 'name' , $ name ) -> delete ( ) ; } | Kicks of the Migration - Down Process |
59,652 | public static function hasMigrated ( string $ name ) { $ res = DB :: connection ( 'default' ) -> table ( 'migrations' ) -> where ( 'name' , $ name ) -> first ( ) ; return ! is_null ( $ res ) ; } | Checks if the given migration has been done already |
59,653 | public static function getLastMigration ( App $ app ) { $ res = DB :: connection ( 'default' ) -> table ( 'migrations' ) -> orderBy ( 'id' , 'desc' ) -> first ( ) ; if ( is_null ( $ res ) || ! $ app -> hasMigration ( $ res -> name ) ) { return false ; } return $ res -> name ; } | Returns the last migration - name which has been done |
59,654 | public static function prepareMigrationTable ( App $ app ) : void { $ migration = new class ( $ app ) extends Migration { public function up ( ) : void { $ schema = $ this -> getSchema ( 'default' ) ; if ( ! $ schema -> hasTable ( 'migrations' ) ) { $ schema -> create ( 'migrations' , function ( Blueprint $ table ) { $... | Prepares the migration table |
59,655 | public function apply ( $ testable , array $ config = array ( ) ) { $ message = '{:name} has no declared visibility.' ; $ tokens = $ testable -> tokens ( ) ; $ classes = $ testable -> findAll ( array ( T_CLASS ) ) ; $ filtered = $ testable -> findAll ( $ this -> inspectableTokens ) ; foreach ( $ classes as $ classId ) ... | Will iterate all the tokens looking for tokens in inspectableTokens The token needs an access modifier if it is a T_FUNCTION or T_VARIABLE and is in the first level of T_CLASS . This prevents functions and variables inside methods and outside classes to register violations . |
59,656 | public function email ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ email ) { if ( strlen ( $ email ) == 0 ) return true ; $ isValid = true ; $ atIndex = strrpos ( $ email , '@' ) ; if ( is_bool ( $ atIndex ) && ! $ atIndex ) { $ isValid = false ; } else { $ domain = substr ( $ email , $ atInde... | Field if completed has to be a valid email address . |
59,657 | public function required ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { if ( is_scalar ( $ val ) ) { $ val = trim ( $ val ) ; } return ! empty ( $ val ) ; } , $ message ) ; return $ this ; } | Field must be filled in . |
59,658 | public function exists ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return null !== $ val ; } , $ message ) ; return $ this ; } | Field must exist even if empty |
59,659 | public function float ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ! ( filter_var ( $ val , FILTER_VALIDATE_FLOAT ) === FALSE ) ; } , $ message ) ; return $ this ; } | Field must contain a valid float value . |
59,660 | public function integer ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ! ( filter_var ( $ val , FILTER_VALIDATE_INT ) === FALSE ) ; } , $ message ) ; return $ this ; } | Field must contain a valid integer value . |
59,661 | public function between ( $ min , $ max , $ include = TRUE , $ message = null ) { $ message = $ this -> _getDefaultMessage ( __FUNCTION__ , array ( $ min , $ max , $ include ) ) ; $ this -> min ( $ min , $ include , $ message ) -> max ( $ max , $ include , $ message ) ; return $ this ; } | Field must be a number between X and Y . |
59,662 | public function minlength ( $ len , $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { return ! ( strlen ( trim ( $ val ) ) < $ args [ 0 ] ) ; } , $ message , array ( $ len ) ) ; return $ this ; } | Field has to be greater than or equal to X characters long . |
59,663 | public function betweenlength ( $ minlength , $ maxlength , $ message = null ) { $ message = empty ( $ message ) ? self :: getDefaultMessage ( __FUNCTION__ , array ( $ minlength , $ maxlength ) ) : NULL ; $ this -> minlength ( $ minlength , $ message ) -> max ( $ maxlength , $ message ) ; return $ this ; } | Field has to be between minlength and maxlength characters long . |
59,664 | public function endsWith ( $ sub , $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { $ sub = $ args [ 0 ] ; return ( strlen ( $ val ) === 0 || substr ( $ val , - strlen ( $ sub ) ) === $ sub ) ; } , $ message , array ( $ sub ) ) ; return $ this ; } | Field must end with a specific substring . |
59,665 | public function ip ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ( strlen ( trim ( $ val ) ) === 0 || filter_var ( $ val , FILTER_VALIDATE_IP ) !== FALSE ) ; } , $ message ) ; return $ this ; } | Field has to be valid IP address . |
59,666 | public function url ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ( strlen ( trim ( $ val ) ) === 0 || filter_var ( $ val , FILTER_VALIDATE_URL ) !== FALSE ) ; } , $ message ) ; return $ this ; } | Field has to be valid internet address . |
59,667 | public function date ( $ message = null , $ format = null , $ separator = '' ) { $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { if ( strlen ( trim ( $ val ) ) === 0 ) { return TRUE ; } try { $ dt = new \ DateTime ( $ val , new \ DateTimeZone ( "UTC" ) ) ; return true ; } catch ( \ Exception $ e ) { re... | Field has to be a valid date . |
59,668 | public function minDate ( $ date = 0 , $ format = null , $ message = null ) { if ( empty ( $ format ) ) { $ format = $ this -> _getDefaultDateFormat ( ) ; } if ( is_numeric ( $ date ) ) { $ date = new \ DateTime ( $ date . ' days' ) ; } else { $ fieldValue = $ this -> _getVal ( $ date ) ; $ date = ( $ fieldValue == FAL... | Field has to be a date later than or equal to X . |
59,669 | public function ccnum ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ value ) { $ value = str_replace ( ' ' , '' , $ value ) ; $ length = strlen ( $ value ) ; if ( $ length < 13 || $ length > 19 ) { return FALSE ; } $ sum = 0 ; $ weight = 2 ; for ( $ i = $ length - 2 ; $ i >= 0 ; $ i -- ) { $ dig... | Field has to be a valid credit card number format . |
59,670 | 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 . |
59,671 | 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 |
59,672 | 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 |
59,673 | public function getAllErrors ( $ keys = true ) { return ( $ keys == true ) ? $ this -> errors : array_values ( $ this -> errors ) ; } | Get all errors . |
59,674 | protected function registerError ( $ rule , $ key , $ message = null ) { if ( empty ( $ message ) ) { $ message = $ this -> messages [ $ rule ] ; } $ this -> errors [ $ key ] = sprintf ( $ message , $ this -> fields [ $ key ] ) ; } | Register error . |
59,675 | 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 . |
59,676 | 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 . |
59,677 | 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 . |
59,678 | 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 . |
59,679 | 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 . |
59,680 | 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 . |
59,681 | 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 |
59,682 | 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 . |
59,683 | public function isAWS ( ) { return in_array ( $ this -> type ( ) , [ TargetEnum :: TYPE_CD , TargetEnum :: TYPE_EB , TargetEnum :: TYPE_S3 ] ) ; } | Is this group for AWS? |
59,684 | 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 . |
59,685 | 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 . |
59,686 | 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 . |
59,687 | 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 . |
59,688 | 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 . |
59,689 | 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 . |
59,690 | 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 . |
59,691 | 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 . |
59,692 | 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 . |
59,693 | 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 |
59,694 | 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 |
59,695 | 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 |
59,696 | 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 |
59,697 | 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 |
59,698 | 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 . |
59,699 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.