idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
57,000
public function setTime ( $ hour , $ minute , $ second = 0 ) { parent :: setTime ( $ hour , $ minute , $ second ) ; return $ this ; }
Set the time all together
57,001
public function diffInMinutes ( Time $ dt = null , $ abs = true ) { return ( int ) ( $ this -> diffInSeconds ( $ dt , $ abs ) / self :: SECONDS_PER_MINUTE ) ; }
Get the difference in minutes
57,002
public function connect ( ) { $ this -> errorHandler -> start ( ) ; $ methods = array ( ) ; if ( $ this -> configuration -> getAuthType ( ) !== 'pass' ) { $ methods [ 'hostkey' ] = $ this -> configuration -> getAuthType ( ) ; } if ( ( $ this -> sshResource = $ this -> driver -> connect ( $ this -> configuration -> getHost ( ) , $ this -> configuration -> getPort ( ) , $ methods ) ) !== false ) { if ( $ this -> configuration -> getAuthType ( ) !== 'pass' ) { $ auth = $ this -> driver -> authPubkey ( $ this -> sshResource , $ this -> configuration -> getUser ( ) , $ this -> configuration -> getPubKey ( ) , $ this -> configuration -> getPrivKey ( ) , $ this -> configuration -> getPassphrase ( ) ) ; } else { $ auth = $ this -> driver -> authPassword ( $ this -> sshResource , $ this -> configuration -> getUser ( ) , $ this -> configuration -> getPass ( ) ) ; } if ( $ auth !== false ) { if ( ( $ this -> resource = $ this -> driver -> sftpStart ( $ this -> sshResource ) ) !== false ) { if ( ( $ this -> dir = $ this -> driver -> realpath ( $ this -> resource , $ this -> configuration -> getDir ( ) ) ) !== false ) { $ this -> errorHandler -> stop ( ) ; return true ; } } } } $ this -> errorHandler -> stop ( ) ; return false ; }
Standard function for creating a SFTP connection and logging in .
57,003
public function put ( $ local , $ remote ) { $ this -> errorHandler -> start ( ) ; if ( $ this -> driver -> scpSend ( $ this -> resource , $ local , $ remote ) ) { $ this -> errorHandler -> stop ( ) ; return true ; } $ this -> errorHandler -> stop ( ) ; return false ; }
Put a local file up to a remote server .
57,004
public function fget ( $ remote ) { if ( $ remote == '' || substr ( $ remote , 0 , 1 ) !== '/' ) { $ remote = $ this -> dir . '/' . $ remote ; } $ this -> errorHandler -> start ( ) ; if ( ( $ handle = $ this -> driver -> sftpFopen ( $ this -> resource , $ remote , 'r+' ) ) !== false ) { rewind ( $ handle ) ; $ this -> errorHandler -> stop ( ) ; return $ handle ; } $ this -> errorHandler -> stop ( ) ; return false ; }
Similar to get but does not save file locally .
57,005
public function cd ( $ dir = '' ) { if ( $ dir == '' || substr ( $ dir , 0 , 1 ) !== '/' ) { $ dir = $ this -> dir . '/' . $ dir ; } $ this -> errorHandler -> start ( ) ; if ( ( $ dir = $ this -> driver -> realpath ( $ this -> resource , $ dir ) ) !== false ) { $ this -> dir = $ dir ; $ this -> errorHandler -> stop ( ) ; return true ; } $ this -> errorHandler -> stop ( ) ; return false ; }
Change the current working directory on the remote machine .
57,006
public function mv ( $ sourcepath , $ destpath ) { $ this -> errorHandler -> start ( ) ; if ( $ sourcepath == '' || substr ( $ sourcepath , 0 , 1 ) !== '/' ) { $ sourcepath = $ this -> dir . '/' . $ sourcepath ; } if ( $ destpath == '' || substr ( $ destpath , 0 , 1 ) !== '/' ) { $ destpath = $ this -> dir . '/' . $ destpath ; } if ( ( $ sourcepath = $ this -> driver -> realpath ( $ this -> resource , $ sourcepath ) ) !== false ) { if ( ( $ this -> driver -> sftpRename ( $ this -> resource , $ sourcepath , $ destpath ) ) !== false ) { $ this -> errorHandler -> stop ( ) ; return true ; } } $ this -> errorHandler -> stop ( ) ; return false ; }
Move a remote file to a new location on the remote server .
57,007
public function rm ( $ sourcepath ) { if ( $ sourcepath == '' || substr ( $ sourcepath , 0 , 1 ) !== '/' ) { $ sourcepath = $ this -> dir . '/' . $ sourcepath ; } $ this -> errorHandler -> start ( ) ; if ( ( $ sourcepath = $ this -> driver -> realpath ( $ this -> resource , $ sourcepath ) ) !== false ) { if ( $ this -> driver -> sftpDelete ( $ this -> resource , $ sourcepath ) ) { $ this -> errorHandler -> stop ( ) ; return true ; } } $ this -> errorHandler -> stop ( ) ; $ this -> errorHandler -> register ( "Could not delete: $sourcepath" , 0 ) ; return false ; }
Remove a file from the remote file system .
57,008
public function run ( ) { if ( ! $ this -> isAppRootSet ( ) ) { throw new Exception ( "The application root wasn't defined." , 1 ) ; } if ( ! $ this -> isConfigFileSet ( ) ) { throw new Exception ( "The main config file wasn't defined." , 2 ) ; } $ sConfigPath = $ this -> getAppRoot ( ) . $ this -> getConfigFile ( ) ; if ( ! is_readable ( $ sConfigPath ) ) { throw new Exception ( "It's unable to load " . $ sConfigPath . 'as main config file.' , 4 ) ; } $ mConfig = include $ sConfigPath ; if ( ! is_array ( $ mConfig ) ) { throw new Exception ( 'The main config must be an array.' , 5 ) ; } $ this -> configSet = $ mConfig ; }
It loads main file of configuration and checks for validity .
57,009
private static function getBaseUrl ( ) { if ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { $ sProtocol = ! empty ( $ _SERVER [ 'HTTPS' ] ) && strtolower ( $ _SERVER [ 'HTTPS' ] ) == 'on' ? 'https' : 'http' ; return $ sProtocol . '://' . $ _SERVER [ 'SERVER_NAME' ] ; } return null ; }
It determines the basic site URL .
57,010
public function getComponentRoot ( $ sName ) { $ aRootMap = $ this -> getConfig ( 'componentsRootMap' ) ; return isset ( $ aRootMap [ $ sName ] ) ? $ this -> getAppRoot ( ) . $ aRootMap [ $ sName ] : null ; }
The method returns full path to the parent directory of component by its name .
57,011
public function branches ( string $ user , string $ repo ) : array { $ default = [ ] ; $ api = $ this -> client -> api ( 'git_data' ) -> references ( ) ; $ params = [ $ api , 'branches' , [ $ user , $ repo ] ] ; $ refs = $ this -> callGitHub ( [ $ this -> pager , 'fetchAll' ] , $ params , $ default ) ; array_walk ( $ refs , function ( & $ data ) { $ data [ 'name' ] = str_replace ( 'refs/heads/' , '' , $ data [ 'ref' ] ) ; } ) ; usort ( $ refs , $ this -> branchSorter ( ) ) ; return $ refs ; }
Get the reference data for branches for a repository .
57,012
public function pullRequests ( string $ user , string $ repo , array $ filter = [ ] ) : array { $ default = [ ] ; $ api = $ this -> client -> api ( 'pull_request' ) ; $ params = [ $ user , $ repo , $ filter ] ; $ refs = $ this -> callGitHub ( [ $ api , 'all' ] , $ params , $ default ) ; usort ( $ refs , $ this -> prSorter ( $ user ) ) ; return $ refs ; }
Get all pull requests for a repository .
57,013
public function pullRequest ( string $ user , string $ repo , string $ number ) : ? array { $ api = $ this -> client -> api ( 'pull_request' ) ; $ params = [ $ user , $ repo , $ number ] ; $ refs = $ this -> callGitHub ( [ $ api , 'show' ] , $ params ) ; return is_array ( $ refs ) ? $ refs : null ; }
Get metadata for a specific pull request .
57,014
public function repository ( string $ user , string $ repo ) : ? array { $ api = $ this -> client -> api ( 'repo' ) ; $ params = [ $ user , $ repo ] ; $ repo = $ this -> callGitHub ( [ $ api , 'show' ] , $ params ) ; return is_array ( $ repo ) ? $ repo : null ; }
Get the extended metadata for a repository .
57,015
public function tags ( string $ user , string $ repo ) : array { $ default = [ ] ; $ api = $ this -> client -> api ( 'git_data' ) -> references ( ) ; $ params = [ $ api , 'tags' , [ $ user , $ repo ] ] ; $ refs = $ this -> callGitHub ( [ $ this -> pager , 'fetchAll' ] , $ params , $ default ) ; array_walk ( $ refs , function ( & $ data ) { $ data [ 'name' ] = str_replace ( 'refs/tags/' , '' , $ data [ 'ref' ] ) ; } ) ; usort ( $ refs , $ this -> tagSorter ( ) ) ; return $ refs ; }
Get the reference data for tags for a repository .
57,016
public function diff ( string $ user , string $ repo , string $ base , string $ head ) { $ api = $ this -> client -> api ( 'repo' ) -> commits ( ) ; $ params = [ $ user , $ repo , $ base , $ head ] ; return $ this -> callGitHub ( [ $ api , 'compare' ] , $ params ) ; }
Compare two git commits
57,017
private function _collapseType ( $ src , $ default ) { $ type = gettype ( $ src ) ; $ typeTargetd = gettype ( $ default ) ; switch ( $ typeTargetd ) { case 'integer' : if ( $ type == "string" || $ type == "integer" ) { return intval ( $ src ) ; } break ; case 'double' : if ( $ type == "string" || $ type == "integer" || $ type == "double" ) { $ src = str_replace ( "," , "." , $ src ) ; return floatval ( $ src ) ; } break ; case 'string' : if ( $ type == 'string' ) { return strval ( $ src ) ; } break ; case 'boolean' : if ( $ type == 'boolean' || $ type == 'string' || $ type == 'integer' ) { return boolval ( $ src ) ; } break ; case 'object' : return new RequestClass ( $ src ) ; break ; case 'array' : return new RequestClass ( $ src ) ; break ; default : } return $ default ; }
Check type of src with default
57,018
private function isEmpty ( $ type ) { switch ( $ type ) { case static :: GET : $ global = & $ _GET ; break ; case static :: POST : $ global = & $ this -> _getPost ( ) ; break ; case static :: SESSION : $ global = & $ _SESSION ; break ; default : throw new \ Exception ( "Unknown global type : " . $ type ) ; break ; } return empty ( $ global ) ; }
Return if the var is empty
57,019
private function unsetGlobal ( $ var , $ type ) { switch ( $ type ) { case static :: GET : $ global = & $ _GET ; break ; case static :: POST : $ global = & $ this -> _getPost ( ) ; break ; case static :: SESSION : $ global = & $ _SESSION ; break ; default : throw new \ Exception ( "Unknown global type : " . $ type ) ; break ; } if ( ! array_key_exists ( $ var , $ global ) ) { return false ; } unset ( $ global [ $ var ] ) ; return true ; }
Unset a var
57,020
function findOneMatchBy ( $ property , $ value ) { switch ( $ property ) { case 'owner_identifier' : return $ this -> federation -> getAccountInfoByUid ( $ value ) ; break ; default : throw new \ Exception ( sprintf ( 'Identity Provider Can`t Attain with (%s).' , $ property ) ) ; } }
Finds a user by the given user Identity .
57,021
public function validateMetadata ( $ requestedType , EntityMetadata $ metadata , MetadataFactory $ mf ) { if ( $ requestedType !== $ metadata -> type ) { throw MetadataException :: invalidMetadata ( $ requestedType , 'Metadata type mismatch.' ) ; } $ this -> validateMetadataType ( $ metadata ) ; if ( null === $ metadata -> persistence ) { throw MetadataException :: invalidMetadata ( $ requestedType , 'No persistence metadata was found. All models must use a persistence layer.' ) ; } $ this -> validateMetadataInheritance ( $ metadata , $ mf ) ; $ this -> validateMetadataAttributes ( $ metadata , $ mf ) ; $ this -> validateMetadataRelationships ( $ metadata , $ mf ) ; $ this -> validateMetadataEmbeds ( $ metadata , $ mf ) ; return true ; }
Validates EntityMetadata .
57,022
public function validateMetadataType ( EntityMetadata $ metadata ) { if ( true === $ metadata -> isChildEntity ( ) ) { $ parentType = $ metadata -> getParentEntityType ( ) ; if ( 0 !== strpos ( $ metadata -> type , $ parentType ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'Child class types must be prefixed by the parent class. Expected "%s" prefix.' , $ parentType ) ) ; } } if ( false === $ this -> isEntityTypeValid ( $ metadata -> type ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'The entity type is invalid based on the configured name format "%s"' , $ this -> config -> getEntityFormat ( ) ) ) ; } return true ; }
Validates the proper entity type on EntityMetadata .
57,023
public function validateMetadataInheritance ( EntityMetadata $ metadata , MetadataFactory $ mf ) { if ( true === $ metadata -> isPolymorphic ( ) ) { foreach ( $ metadata -> ownedTypes as $ child ) { if ( false === $ this -> isEntityTypeValid ( $ child ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'The owned entity type "%s" is invalid based on the configured name format "%s"' , $ child , $ this -> config -> getEntityFormat ( ) ) ) ; } if ( false === $ mf -> metadataExists ( $ child ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'The entity owns a type "%s" that does not exist.' , $ child ) ) ; } } } if ( false === $ metadata -> isPolymorphic ( ) && true === $ metadata -> isAbstract ( ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , 'An entity must be polymorphic to be abstract.' ) ; } if ( false === $ metadata -> isChildEntity ( ) ) { return true ; } if ( true === $ metadata -> isPolymorphic ( ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , 'An entity cannot both be polymorphic and be a child.' ) ; } if ( $ metadata -> extends === $ metadata -> type ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , 'An entity cannot extend itself.' ) ; } if ( false === $ mf -> metadataExists ( $ metadata -> extends ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'The parent entity type "%s" does not exist.' , $ metadata -> extends ) ) ; } $ parent = $ mf -> getMetadataForType ( $ metadata -> extends ) ; if ( false === $ parent -> isPolymorphic ( ) ) { throw MetadataException :: invalidMetadata ( $ metadata -> type , sprintf ( 'Parent classes must be polymorphic. Parent entity "%s" is not polymorphic.' , $ metadata -> extends ) ) ; } return true ; }
Validates the proper entity inheritance on EntityMetadata .
57,024
public function validateMetadataAttributes ( AttributeInterface $ metadata , MetadataFactory $ mf ) { $ type = $ metadata instanceof EntityMetadata ? $ metadata -> type : ( property_exists ( $ metadata , 'name' ) ? $ metadata -> name : '' ) ; foreach ( $ metadata -> getAttributes ( ) as $ key => $ attribute ) { if ( $ key != $ attribute -> key ) { throw MetadataException :: invalidMetadata ( $ type , sprintf ( 'Attribute key mismtach. "%s" !== "%s"' , $ key , $ attribute -> key ) ) ; } if ( false === $ this -> isFieldKeyValid ( $ attribute -> key ) ) { throw MetadataException :: invalidMetadata ( $ type , sprintf ( 'The attribute key "%s" is invalid based on the configured name format "%s"' , $ attribute -> key , $ this -> config -> getFieldKeyFormat ( ) ) ) ; } if ( false === $ this -> typeFactory -> hasType ( $ attribute -> dataType ) ) { throw MetadataException :: invalidMetadata ( $ type , sprintf ( 'The data type "%s" for attribute "%s" is invalid' , $ attribute -> dataType , $ attribute -> key ) ) ; } if ( $ metadata instanceof EntityMetadata && true === $ metadata -> isChildEntity ( ) ) { $ parent = $ mf -> getMetadataForType ( $ metadata -> extends ) ; if ( $ parent -> hasAttribute ( $ attribute -> key ) ) { throw MetadataException :: invalidMetadata ( $ type , sprintf ( 'Parent entity type "%s" already contains attribute field "%s"' , $ parent -> type , $ attribute -> key ) ) ; } } if ( true === $ attribute -> isCalculated ( ) ) { if ( false === class_exists ( $ attribute -> calculated [ 'class' ] ) || false === method_exists ( $ attribute -> calculated [ 'class' ] , $ attribute -> calculated [ 'method' ] ) ) { throw MetadataException :: invalidMetadata ( $ type , sprintf ( 'The attribute field "%s" is calculated, but was unable to find method "%s:%s"' , $ attribute -> key , $ attribute -> calculated [ 'class' ] , $ attribute -> calculated [ 'method' ] ) ) ; } } } return true ; }
Validates entity attributes on the AttributeInterface .
57,025
protected function formatValue ( $ format , $ value ) { switch ( $ format ) { case 'dash' : return $ this -> inflector -> dasherize ( $ value ) ; case 'underscore' : return $ this -> inflector -> underscore ( $ value ) ; case 'studlycaps' : return $ this -> inflector -> studlify ( $ value ) ; case 'camelcase' : return $ this -> inflector -> camelize ( $ value ) ; default : throw new RuntimeException ( 'Unable to format value' ) ; } }
Formats a value based on a formatting type .
57,026
public function setRoute ( array $ methods , string $ regexp , $ callable ) : RouteInterface { return $ this -> setMethods ( $ methods ) -> setRegexp ( $ regexp ) -> setCallback ( $ callable ) ; }
Set single route
57,027
public function setRegexp ( string $ regexp ) : RouteInterface { $ pattern = [ '/</' , '/>/' ] ; $ replace = [ '(?P<' , '>.+)' ] ; $ regexp = preg_replace ( $ pattern , $ replace , $ regexp ) ; $ this -> _regexp = '#^' . $ regexp . '$#u' ; return $ this ; }
Set regexp of current route
57,028
public function route ( string $ method , string $ path ) : Route { if ( ! HttpMethod :: isValid ( $ method ) ) { throw new \ InvalidArgumentException ( "Invalid HTTP method '$method'" ) ; } $ this -> allowedMethods = [ ] ; $ segments = split_segments ( $ path ) ; $ routes = $ this -> matchRoutes ( $ method , $ segments ) ; if ( \ count ( $ routes ) === 1 ) { return $ routes [ 0 ] ; } if ( \ count ( $ routes ) !== 0 ) { throw new \ UnexpectedValueException ( "The given path '$path' matches more than one route" ) ; } if ( \ count ( $ this -> allowedMethods ) > 0 ) { if ( \ in_array ( HttpMethod :: GET , $ this -> allowedMethods , true ) ) { $ this -> allowedMethods [ ] = HttpMethod :: HEAD ; } throw new MethodNotAllowedException ( "The requested method '$method' is not within list of allowed methods" , array_values ( array_intersect ( HttpMethod :: getAll ( ) , $ this -> allowedMethods ) ) ) ; } throw new RouteNotFoundException ( "The given path '$path' did not match any defined route" ) ; }
Routes the given path with the given HTTP request method to a specific route .
57,029
private function matchRoutes ( string $ method , array $ segments ) : array { $ staticIds = $ this -> provider -> getRoutesByStaticPath ( implode ( '/' , $ segments ) ) ; if ( $ staticIds !== [ ] ) { $ routes = $ this -> getMatchingRoutes ( $ staticIds , $ method , $ segments ) ; if ( $ routes !== [ ] ) { return $ routes ; } } if ( $ segments === [ ] ) { return [ ] ; } $ matchedIds = $ this -> getDynamicRouteIds ( $ segments ) ; return $ this -> getMatchingRoutes ( $ matchedIds , $ method , $ segments ) ; }
Returns routes that match the given HTTP request method and path segments .
57,030
private function getDynamicRouteIds ( array $ segments ) : array { $ matched = [ ] ; $ index = 0 ; do { $ matched [ ] = $ this -> provider -> getRoutesBySegmentValue ( $ index , $ segments [ $ index ] ) + $ this -> provider -> getRoutesBySegmentValue ( $ index , RouteDefinition :: DYNAMIC_SEGMENT ) ; $ index ++ ; } while ( isset ( $ segments [ $ index ] ) ) ; $ matched [ ] = $ this -> provider -> getRoutesBySegmentCount ( \ count ( $ segments ) ) ; return array_values ( array_intersect_key ( ... $ matched ) ) ; }
Returns a list of route ids for dynamic routes that have matching static path segments .
57,031
private function getMatchingRoutes ( array $ ids , string $ method , array $ segments ) : array { $ routes = [ ] ; foreach ( $ ids as $ id ) { $ definition = $ this -> provider -> getRouteDefinition ( $ id ) ; $ values = [ ] ; if ( ! $ definition -> matchPatterns ( $ segments , $ values ) ) { continue ; } if ( ! $ definition -> isMethodAllowed ( $ method ) ) { array_push ( $ this -> allowedMethods , ... $ definition -> getMethods ( ) ) ; continue ; } $ routes [ ] = new Route ( $ definition , $ method , $ segments , $ values ) ; } return $ routes ; }
Returns the routes for the given ids that match the requested method and segments .
57,032
public function generateUrl ( string $ name , array $ parameters = [ ] ) : string { $ definition = $ this -> provider -> getRouteDefinitionByName ( $ name ) ; return $ definition -> formatUrl ( $ parameters ) ; }
Returns the encoded URL for the route with the given name .
57,033
public function finalize ( ) { if ( ! $ this -> finalized ) { foreach ( $ this -> getRoutes ( ) as $ route ) { $ route -> finalize ( ) ; $ this -> addRoute ( $ route -> getMethods ( ) , $ route -> getPattern ( ) , [ $ route , 'run' ] ) ; } $ this -> finalized = true ; } }
Finalize registered routes in preparation for dispatching .
57,034
public function getNamedRoute ( $ name ) { if ( is_null ( $ this -> namedRoutes ) ) { $ this -> buildNameIndex ( ) ; } if ( ! isset ( $ this -> namedRoutes [ $ name ] ) ) { throw new RuntimeException ( 'Named route does not exist for name: ' . $ name ) ; } return $ this -> namedRoutes [ $ name ] ; }
Get named route object .
57,035
public function urlFor ( $ name , array $ data = [ ] , array $ queryParams = [ ] ) { trigger_error ( 'urlFor() is deprecated. Use pathFor() instead.' , E_USER_DEPRECATED ) ; return $ this -> pathFor ( $ name , $ data , $ queryParams ) ; }
Build the path for a named route .
57,036
protected function buildNameIndex ( ) { $ this -> namedRoutes = [ ] ; foreach ( $ this -> routes as $ route ) { $ name = $ route -> getName ( ) ; if ( $ name ) { $ this -> namedRoutes [ $ name ] = $ route ; } } }
Build index of named routes .
57,037
public function addOrderBy ( QueryBuilder $ queryBuilder , Request $ request , TableModel $ table ) { $ sorting = $ table -> getSorting ( ) ; $ rootAlias = $ this -> getRootAlias ( $ queryBuilder ) ; $ orderByField = $ request -> query -> get ( 'order_by' , null ) ; $ orderDirection = $ request -> query -> get ( 'order_dir' , null ) ; if ( null !== $ orderByField && true === in_array ( $ orderByField , $ sorting -> getSortableFields ( ) ) ) { $ sorting -> setIndex ( $ orderByField ) ; } if ( null !== $ orderDirection && true === in_array ( strtolower ( $ orderDirection ) , $ this -> getOrderDirections ( ) ) ) { $ sorting -> setDirection ( $ orderDirection ) ; } $ queryBuilder -> orderBy ( sprintf ( "%s.%s" , $ rootAlias , $ sorting -> getIndex ( ) ) , $ sorting -> getDirection ( ) ) ; return $ queryBuilder ; }
Add Order By
57,038
public function saveTableToSession ( Request $ request , TableModel $ table ) { $ request -> getSession ( ) -> set ( TableModel :: buildSessionPath ( $ request ) , serialize ( $ table ) ) ; }
Save Table To Session
57,039
public function loadTableFromSession ( Request $ request ) { $ table = $ request -> getSession ( ) -> get ( TableModel :: buildSessionPath ( $ request ) ) ; if ( true === is_string ( $ table ) ) { return unserialize ( $ table ) ; } return null ; }
Load Table From Session
57,040
public function get ( $ sKey = '' ) { if ( empty ( $ sKey ) ) { return $ this -> store ; } else { return isset ( $ this -> store [ $ sKey ] ) ? $ this -> store [ $ sKey ] : null ; } }
It returns the variable value getted by the name from the storage .
57,041
public function handle ( ) { if ( ! auth ( ) -> user ( ) ) { return false ; } publish ( 'search' , 'scripts.resources' ) ; $ search = Input :: get ( 'search' ) ; $ string = serialize ( [ 'protection_string' => config ( 'antares/search::protection_string' ) , 'app_key' => env ( 'APP_KEY' ) , 'time' => time ( ) ] ) ; $ protectionString = Crypt :: encrypt ( $ string ) ; $ this -> app -> make ( 'antares.widget' ) -> make ( 'placeholder.global_search' ) -> add ( 'search' ) -> value ( view ( 'antares/search::admin.partials._search' , compact ( 'search' , 'protectionString' ) ) ) ; }
up component search placeholder
57,042
public function flush ( ) { try { $ this -> helper -> recursivelyDeleteFromDirectory ( $ this -> path ) ; return true ; } catch ( \ Exception $ e ) { } return false ; }
Flush all existing Cache .
57,043
private function getFolderPathFromMd5 ( $ md5 ) { $ folderOne = substr ( $ md5 , 0 , 2 ) ; $ folderTwo = substr ( $ md5 , 2 , 2 ) ; return $ folderOne . self :: DS . $ folderTwo ; }
Get a folder path from a given MD5
57,044
public function squash ( ) : Collection { if ( count ( $ this -> stack ) || ! ( $ this -> array instanceof \ ArrayObject ) ) { $ this -> array = new \ ArrayObject ( iterator_to_array ( $ this ) ) ; $ this -> stack = [ ] ; $ this -> iterator = $ this -> array -> getIterator ( ) ; } return $ this ; }
Applies all pending operations
57,045
public function count ( ) { if ( count ( $ this -> stack ) || ! ( $ this -> array instanceof \ Countable ) ) { $ this -> squash ( ) ; } return $ this -> array -> count ( ) ; }
Get the collection length
57,046
public function extend ( $ source ) : Collection { if ( ! is_array ( $ source ) ) { $ source = iterator_to_array ( $ source ) ; } return new static ( array_merge ( $ this -> toArray ( ) , $ source ) ) ; }
Append more values to the collection
57,047
public function flatten ( ) : Collection { $ rslt = [ ] ; $ temp = $ this -> toArray ( ) ; foreach ( $ temp as $ v ) { $ rslt = array_merge ( $ rslt , is_array ( $ v ) ? $ v : [ $ v ] ) ; } return new static ( $ rslt ) ; }
Perform a shallow flatten of the collection
57,048
public function first ( int $ count = 1 ) : Collection { $ i = 0 ; $ new = [ ] ; foreach ( $ this as $ k => $ v ) { if ( ++ $ i > $ count ) { break ; } $ new [ $ k ] = $ v ; } return new static ( $ new ) ; }
Get the first X items from the collection
57,049
public function shuffle ( ) : Collection { $ temp = $ this -> toArray ( ) ; $ keys = array_keys ( $ temp ) ; shuffle ( $ keys ) ; $ rslt = [ ] ; foreach ( $ keys as $ key ) { $ rslt [ $ key ] = $ temp [ $ key ] ; } return new static ( $ rslt ) ; }
Shuffle the values in the collection
57,050
public function unique ( ) : Collection { $ temp = $ this -> toArray ( ) ; $ rslt = [ ] ; foreach ( $ temp as $ k => $ v ) { if ( ! in_array ( $ v , $ rslt , true ) ) { $ rslt [ $ k ] = $ v ; } } return new static ( $ rslt ) ; }
Leave only unique items in the collection
57,051
public function where ( array $ properties , $ strict = true ) : Collection { return $ this -> filter ( function ( $ v ) use ( $ properties , $ strict ) { return $ this -> whereCallback ( $ v , $ properties , $ strict ) ; } ) ; }
Filter items from the collection using key = > value pairs
57,052
public function zip ( $ keys ) : Collection { if ( ! is_array ( $ keys ) ) { $ keys = iterator_to_array ( $ keys ) ; } return new static ( array_combine ( $ keys , $ this -> toArray ( ) ) ) ; }
Combine all the values from the collection with a key
57,053
public function all ( callable $ iterator ) : bool { foreach ( $ this as $ k => $ v ) { if ( ! call_user_func ( $ iterator , $ v , $ k , $ this ) ) { return false ; } } return true ; }
Do all of the items in the collection match a given criteria
57,054
public function contains ( $ needle ) : bool { foreach ( $ this as $ k => $ v ) { if ( $ v === $ needle ) { return true ; } } return false ; }
Does the collection contain a given value
57,055
public function min ( ) { $ min = null ; $ first = false ; foreach ( $ this as $ v ) { if ( ! $ first || $ v < $ min ) { $ min = $ v ; $ first = true ; } } return $ min ; }
Get the minimal item in the collection
57,056
public function max ( ) { $ max = null ; $ first = false ; foreach ( $ this as $ v ) { if ( ! $ first || $ v > $ max ) { $ max = $ v ; $ first = true ; } } return $ max ; }
Get the maximum item in the collection
57,057
public function reduce ( callable $ iterator , $ initial = null ) { foreach ( $ this as $ k => $ v ) { $ initial = $ iterator ( $ initial , $ v , $ k , $ this ) ; } return $ initial ; }
Reduce the collection to a single value
57,058
public function createOauth ( array $ config = [ ] ) { return new Oauth1 ( array_merge ( $ this -> config , [ 'token' => $ this -> tokenStorage -> getAccessToken ( ) , 'token_secret' => $ this -> tokenStorage -> getAccessTokenSecret ( ) , ] , $ config ) ) ; }
Create an OAuth signer and optionally override some of the default config options .
57,059
public function bin_dumpfile ( $ files , $ user_vars , $ filename , $ flags = 0 , $ context = null ) { return apc_bin_dumpfile ( $ files , $ user_vars , $ filename , $ flags , $ context ) ; }
Output a binary dump of the given files and user variables from the APC cache to the named file
57,060
public function compile_file ( $ file_name = '' , $ atomic = false ) { if ( empty ( $ file_name ) ) return false ; return apc_compile_file ( $ file_name , $ atomic ) ; }
Stores a file in the bytecode cache bypassing all filters
57,061
public function setAttribute ( $ name , $ value = null ) { $ this -> getAttributes ( ) -> set ( $ name , $ value ) ; return $ this ; }
Set an HTML tag attribute
57,062
public function getAttribute ( $ name , $ default = null ) { $ value = $ default ; if ( $ this -> hasAttribute ( $ name ) ) { $ value = $ this -> attributes -> get ( $ name ) ; } return $ value ; }
Gets the value of the attribute with the provided name
57,063
protected function check ( $ env_var , $ functionName ) { if ( $ value = fp_env ( $ env_var , null ) ) { if ( $ this -> $ functionName ( ) ) { return $ value ; } $ this -> error ( "Be careful! The $env_var you provided doesn't match Laravel Forge server" ) ; return "<error>$value</error>" ; } else { return 'Not available!' ; } }
Check and obtain ip .
57,064
public static function getRootPath ( ) { if ( is_null ( static :: $ _filePath ) ) { if ( defined ( 'APPLICATION_PATH' ) ) { static :: $ _filePath = APPLICATION_PATH ; } else { static :: $ _filePath = dirname ( dirname ( __FILE__ ) ) ; } } return static :: $ _filePath ; }
Retrieve real root path with last directory separator
57,065
public static function backtrace ( $ return = false , $ html = true , $ withArgs = true ) { $ trace = debug_backtrace ( ) ; return static :: trace ( $ trace , $ return , $ html , $ withArgs ) ; }
Prints or return a backtrace
57,066
public static function trace ( array $ trace , $ return = false , $ html = true , $ withArgs = true ) { $ out = '' ; if ( $ html ) { $ out .= '<pre>' ; } foreach ( $ trace as $ i => $ data ) { if ( $ i == 0 ) { continue ; } $ args = array ( ) ; if ( isset ( $ data [ 'args' ] ) && true === $ withArgs ) { foreach ( $ data [ 'args' ] as $ arg ) { $ args [ ] = static :: _formatCalledArgument ( $ arg ) ; } } if ( isset ( $ data [ 'class' ] ) && isset ( $ data [ 'function' ] ) ) { if ( isset ( $ data [ 'object' ] ) && get_class ( $ data [ 'object' ] ) != $ data [ 'class' ] ) { $ className = get_class ( $ data [ 'object' ] ) . '[' . $ data [ 'class' ] . ']' ; } else { $ className = $ data [ 'class' ] ; } if ( isset ( $ data [ 'object' ] ) ) { $ className .= sprintf ( '#%s#' , spl_object_hash ( $ data [ 'object' ] ) ) ; } $ methodName = sprintf ( '%s%s%s(%s)' , $ className , isset ( $ data [ 'type' ] ) ? $ data [ 'type' ] : '->' , $ data [ 'function' ] , join ( ', ' , $ args ) ) ; } else if ( isset ( $ data [ 'function' ] ) ) { $ methodName = sprintf ( '%s(%s)' , $ data [ 'function' ] , join ( ', ' , $ args ) ) ; } if ( isset ( $ data [ 'file' ] ) ) { $ pos = strpos ( $ data [ 'file' ] , static :: getRootPath ( ) ) ; if ( $ pos !== false ) { $ data [ 'file' ] = substr ( $ data [ 'file' ] , strlen ( static :: getRootPath ( ) ) + 1 ) ; } $ fileName = sprintf ( '%s:%d' , $ data [ 'file' ] , $ data [ 'line' ] ) ; } else { $ fileName = false ; } if ( $ fileName ) { $ out .= sprintf ( '#%d %s called at [%s]' , $ i , $ methodName , $ fileName ) ; } else { $ out .= sprintf ( '#%d %s' , $ i , $ methodName ) ; } $ out .= "\n" ; } if ( true === $ html ) { $ out .= '</pre>' ; } if ( true === $ return ) { return $ out ; } else { echo $ out ; return true ; } }
Prints or return a trace
57,067
protected static function _formatCalledArgument ( $ arg ) { $ out = '' ; if ( is_object ( $ arg ) ) { $ out .= sprintf ( "&%s#%s#" , get_class ( $ arg ) , spl_object_hash ( $ arg ) ) ; } else if ( is_resource ( $ arg ) ) { $ out .= '#[' . get_resource_type ( $ arg ) . ']' ; } else if ( Arrays :: isArray ( $ arg ) ) { $ isAssociative = false ; $ args = array ( ) ; foreach ( $ arg as $ k => $ v ) { if ( ! is_numeric ( $ k ) ) { $ isAssociative = true ; } $ args [ $ k ] = static :: _formatCalledArgument ( $ v ) ; } if ( $ isAssociative ) { $ arr = array ( ) ; foreach ( $ args as $ k => $ v ) { $ arr [ ] = static :: _formatCalledArgument ( $ k ) . ' => ' . $ v ; } $ out .= 'array(' . join ( ', ' , $ arr ) . ')' ; } else { $ out .= 'array(' . join ( ', ' , $ args ) . ')' ; } } else if ( is_null ( $ arg ) ) { $ out .= 'NULL' ; } else if ( is_numeric ( $ arg ) || is_float ( $ arg ) ) { $ out .= $ arg ; } else if ( is_string ( $ arg ) ) { if ( strlen ( $ arg ) > static :: $ argLength ) { $ arg = substr ( $ arg , 0 , static :: $ argLength ) . "..." ; } $ arg = strtr ( $ arg , array ( "\t" => '\t' , "\r" => '\r' , "\n" => '\n' , "'" => '\\\'' ) ) ; $ out .= "'" . $ arg . "'" ; } else if ( is_bool ( $ arg ) ) { $ out .= $ arg === true ? 'true' : 'false' ; } return $ out ; }
Format argument in called method
57,068
public function migrate ( ) : array { $ result = $ this -> getFactory ( ) -> createPropelCommandProvider ( ) -> execute ( 'migration:diff' ) ; return array_merge ( $ result , $ this -> getFactory ( ) -> createPropelCommandProvider ( ) -> execute ( 'migration:migrate' ) ) ; }
Runs all migrations
57,069
private function obtenerControlador ( $ nombre , Peticion $ peticion , Respuesta $ respuesta , Ruta $ ruta ) { $ clase = $ nombre . 'Controlador' ; if ( ! class_exists ( $ clase ) ) { $ archivo = $ this -> dirApp . DIRECTORY_SEPARATOR . 'controladores' . DIRECTORY_SEPARATOR . str_replace ( '\\' , DIRECTORY_SEPARATOR , $ nombre ) . '.php' ; if ( ! is_file ( $ archivo ) ) { throw new \ RuntimeException ( "El archivo del controlador '{$nombre}' no existe." ) ; } require_once $ archivo ; if ( ! class_exists ( $ clase ) ) { throw new \ RuntimeException ( "La clase del controlador '{$nombre}' no existe." ) ; } } return new $ clase ( $ this , $ peticion , $ respuesta , $ ruta ) ; }
Devuelve la instancia del controlador usando su nombre .
57,070
public static function detect ( $ html , & $ error = '' ) { if ( class_exists ( 'Whoops\Run' ) ) { return false ; } if ( strpos ( $ html , '<h2>Message</h2> <pre>' ) != false ) { preg_match ( '/<h2>Message<\/h2> <pre>(.*)<\/pre>/' , $ html , $ output_array ) ; $ error = trim ( strip_tags ( $ output_array [ 0 ] ) ) ; return true ; } return false ; }
Function detect Takes care of detecting if a Basic error was passed and if true extracting the error code to return it by reference
57,071
public function forkAndRunService ( $ bootstrap ) { if ( ! is_callable ( $ bootstrap ) ) { throw new \ RuntimeException ( '$bootstrap must be callable.' ) ; } if ( $ this -> service !== null ) { throw new \ RuntimeException ( 'Service already started.' ) ; } $ serviceAddress = $ this -> getServiceAddress ( ) ; $ factory = $ this -> getSocketFactory ( ) ; $ logger = $ this -> getLogger ( ) ; try { $ this -> service = PidTracker :: fork ( function ( ) use ( $ bootstrap , $ serviceAddress , $ factory , $ logger ) { $ socket = $ factory -> createReply ( Factory :: MODE_CONNECT , $ serviceAddress ) ; $ service = new Service ( $ socket ) ; $ service -> setLogger ( $ logger ) ; call_user_func ( $ bootstrap , $ service ) ; $ service -> run ( ) ; } ) ; $ this -> getLogger ( ) -> info ( 'Service (PID: ' . $ this -> service -> getPid ( ) . ') started.' ) ; } catch ( \ RuntimeException $ ex ) { $ this -> getLogger ( ) -> error ( $ ex -> getMessage ( ) ) ; throw $ ex ; } return $ this ; }
Start the Service .
57,072
public function run ( ) { pcntl_signal_dispatch ( ) ; if ( $ this -> service == null || ! $ this -> service -> isAlive ( ) ) { throw new \ RuntimeException ( 'Service not running.' ) ; } $ workerHandlerSocket = $ this -> socketFactory -> createRequest ( Factory :: MODE_CONNECT , $ this -> workerHandlerAddress ) ; $ serviceSocket = $ this -> socketFactory -> createRequest ( Factory :: MODE_BIND , $ this -> serviceAddress ) ; $ this -> worker = new Worker ( ) ; $ this -> worker -> setLogger ( $ this -> getLogger ( ) ) ; $ comm = new WorkerCommunication ( $ this -> worker , $ workerHandlerSocket , $ serviceSocket ) ; $ comm -> setLogger ( $ this -> getLogger ( ) ) ; $ comm -> setDelay ( $ this -> delay ) ; $ this -> registerSignalHandler ( ) ; $ this -> running = true ; $ comm -> start ( ) ; while ( true ) { $ comm -> process ( ) ; pcntl_signal_dispatch ( ) ; if ( ! $ this -> service -> isAlive ( ) ) { $ this -> worker -> onServiceDown ( ) ; } if ( $ this -> worker -> getState ( ) == Worker :: INVALID ) { $ this -> stop ( ) ; break ; } } $ this -> service -> killAndWait ( ) ; $ this -> worker -> onServiceDown ( ) ; $ this -> getLogger ( ) -> debug ( 'Run completed with state: ' . $ this -> worker -> getState ( ) ) ; }
Run the worker .
57,073
public function stop ( $ signal = null ) { if ( ! $ this -> running ) { return ; } if ( null !== $ signal ) { $ this -> getLogger ( ) -> info ( 'Stop called because of signal #' . $ signal . '. Current state: ' . $ this -> worker -> getState ( ) . '.' ) ; } else { $ this -> getLogger ( ) -> info ( 'Stop called: ' . $ this -> worker -> getState ( ) . '.' ) ; } $ this -> running = false ; $ this -> worker -> shutdown ( ) ; }
Stops this Worker .
57,074
public function index ( array $ input = array ( ) , $ category = null ) { $ query = e ( array_get ( $ input , 'search.value' , null ) ) ; if ( ! is_null ( $ category ) ) { return $ this -> category ( $ query , $ category ) ; } $ this -> breadcrumb -> onIndex ( ) ; $ datatables = config ( 'search.datatables' ) ; $ tabs = [ ] ; foreach ( $ datatables as $ datatable ) { if ( ! class_exists ( $ datatable ) ) { continue ; } $ datatable = app ( $ datatable ) ; $ row = $ datatable -> getQuickSearchRow ( ) ; $ category = array_get ( $ row , 'category' ) ; $ tabs [ camel_case ( $ category ) ] = [ 'title' => $ category , 'datatable' => $ datatable -> render ( 'antares/search::admin.partials._datatable' ) -> render ( ) , ] ; } return view ( 'antares/search::admin.index.index' , compact ( 'tabs' ) ) ; }
Default index action
57,075
public function onTemplateCreated ( TemplateEvent $ event ) { $ template = $ event -> getTemplate ( ) ; $ zones = $ template -> getZones ( ) ; foreach ( $ template -> getTemplateType ( ) -> getZoneTypes ( ) as $ zoneType ) { if ( $ zones -> search ( array ( 'zoneType' => $ zoneType ) ) -> isEmpty ( ) ) { if ( null === $ this -> zoneDomain ) { throw new \ DomainException ( 'No zoneDomain was set, you are unable to update your configuration.' ) ; } $ zones -> add ( $ this -> zoneDomain -> create ( $ zoneType ) ) ; } } $ template -> setZones ( $ zones ) ; }
Template creation event handler .
57,076
static protected function createException ( $ value , $ message , $ code , $ propertyPath , array $ constraints = array ( ) ) { $ constraintString = 'Constraints: ' ; if ( count ( $ constraints ) ) { foreach ( $ constraints as $ key => $ v ) { $ constraintString .= "$key => $v, " ; } $ constraintString = substr ( $ $ constraintString , 0 , - 2 ) ; } return new Exception ( "$message => $code => $value => $propertyPath => $constraintString" ) ; }
Helper method that handles building the assertion failure exceptions . They are returned from this method so that the stack trace still shows the assertions method .
57,077
static public function integer ( $ value , $ message = null , $ propertyPath = null ) { if ( ! is_int ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not an integer.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_INTEGER , $ propertyPath ) ; } }
Assert that value is a php integer .
57,078
static public function float ( $ value , $ message = null , $ propertyPath = null ) { if ( ! is_float ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not a float.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_FLOAT , $ propertyPath ) ; } }
Assert that value is a php float .
57,079
static public function digit ( $ value , $ message = null , $ propertyPath = null ) { if ( ! ctype_digit ( ( string ) $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not a digit.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_DIGIT , $ propertyPath ) ; } }
Validates if an integer or integerish is a digit .
57,080
static public function integerish ( $ value , $ message = null , $ propertyPath = null ) { if ( strval ( intval ( $ value ) ) != $ value || is_bool ( $ value ) || is_null ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not an integer or a number castable to integer.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_INTEGERISH , $ propertyPath ) ; } }
Assert that value is a php integer ish .
57,081
static public function boolean ( $ value , $ message = null , $ propertyPath = null ) { if ( ! is_bool ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not a boolean.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_BOOLEAN , $ propertyPath ) ; } }
Assert that value is php boolean
57,082
static public function notEmpty ( $ value , $ message = null , $ propertyPath = null ) { if ( empty ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is empty, but non empty value was expected.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: VALUE_EMPTY , $ propertyPath ) ; } }
Assert that value is not empty
57,083
static public function noContent ( $ value , $ message = null , $ propertyPath = null ) { if ( ! empty ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not empty, but empty value was expected.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: VALUE_NOT_EMPTY , $ propertyPath ) ; } }
Assert that value is empty
57,084
static public function notNull ( $ value , $ message = null , $ propertyPath = null ) { if ( $ value === null ) { $ message = $ message ? : sprintf ( 'Value "%s" is null, but non null value was expected.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: VALUE_NULL , $ propertyPath ) ; } }
Assert that value is not null
57,085
static public function string ( $ value , $ message = null , $ propertyPath = null ) { if ( ! is_string ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" expected to be string, type %s given.' , static :: stringify ( $ value ) , gettype ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_STRING , $ propertyPath ) ; } }
Assert that value is a string
57,086
static public function regex ( $ value , $ pattern , $ message = null , $ propertyPath = null ) { static :: string ( $ value , $ message ) ; if ( ! preg_match ( $ pattern , $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" does not match expression.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_REGEX , $ propertyPath , array ( 'pattern' => $ pattern ) ) ; } }
Assert that value matches a regex
57,087
static public function length ( $ value , $ length , $ message = null , $ propertyPath = null , $ encoding = 'utf8' ) { static :: string ( $ value , $ message ) ; if ( mb_strlen ( $ value , $ encoding ) !== $ length ) { $ message = $ message ? : sprintf ( 'Value "%s" has to be %d exactly characters long, but length is %d.' , static :: stringify ( $ value ) , $ length , mb_strlen ( $ value , $ encoding ) ) ; $ constraints = array ( 'length' => $ length , 'encoding' => $ encoding ) ; throw static :: createException ( $ value , $ message , static :: INVALID_LENGTH , $ propertyPath , $ constraints ) ; } }
Assert that string has a given length .
57,088
static public function betweenLength ( $ value , $ minLength , $ maxLength , $ message = null , $ propertyPath = null , $ encoding = 'utf8' ) { static :: string ( $ value , $ message ) ; if ( mb_strlen ( $ value , $ encoding ) < $ minLength ) { $ message = $ message ? : sprintf ( 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.' , static :: stringify ( $ value ) , $ minLength , mb_strlen ( $ value , $ encoding ) ) ; $ constraints = array ( 'min_length' => $ minLength , 'encoding' => $ encoding ) ; throw static :: createException ( $ value , $ message , static :: INVALID_MIN_LENGTH , $ propertyPath , $ constraints ) ; } if ( mb_strlen ( $ value , $ encoding ) > $ maxLength ) { $ message = $ message ? : sprintf ( 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.' , static :: stringify ( $ value ) , $ maxLength , mb_strlen ( $ value , $ encoding ) ) ; $ constraints = array ( 'max_length' => $ maxLength , 'encoding' => $ encoding ) ; throw static :: createException ( $ value , $ message , static :: INVALID_MAX_LENGTH , $ propertyPath , $ constraints ) ; } }
Assert that string length is between min max lengths .
57,089
static public function startsWith ( $ string , $ needle , $ message = null , $ propertyPath = null , $ encoding = 'utf8' ) { static :: string ( $ string ) ; if ( mb_strpos ( $ string , $ needle , null , $ encoding ) !== 0 ) { $ message = $ message ? : sprintf ( 'Value "%s" does not start with "%s".' , static :: stringify ( $ string ) , static :: stringify ( $ needle ) ) ; $ constraints = array ( 'needle' => $ needle , 'encoding' => $ encoding ) ; throw static :: createException ( $ string , $ message , static :: INVALID_STRING_START , $ propertyPath , $ constraints ) ; } }
Assert that string starts with a sequence of chars .
57,090
static public function endsWith ( $ string , $ needle , $ message = null , $ propertyPath = null , $ encoding = 'utf8' ) { static :: string ( $ string ) ; $ stringPosition = mb_strlen ( $ string , $ encoding ) - mb_strlen ( $ needle , $ encoding ) ; if ( mb_strripos ( $ string , $ needle , null , $ encoding ) !== $ stringPosition ) { $ message = $ message ? : sprintf ( 'Value "%s" does not end with "%s".' , static :: stringify ( $ string ) , static :: stringify ( $ needle ) ) ; $ constraints = array ( 'needle' => $ needle , 'encoding' => $ encoding ) ; throw static :: createException ( $ string , $ message , static :: INVALID_STRING_END , $ propertyPath , $ constraints ) ; } }
Assert that string ends with a sequence of chars .
57,091
static public function contains ( $ string , $ needle , $ message = null , $ propertyPath = null , $ encoding = 'utf8' ) { static :: string ( $ string ) ; if ( mb_strpos ( $ string , $ needle , null , $ encoding ) === false ) { $ message = $ message ? : sprintf ( 'Value "%s" does not contain "%s".' , static :: stringify ( $ string ) , static :: stringify ( $ needle ) ) ; $ constraints = array ( 'needle' => $ needle , 'encoding' => $ encoding ) ; throw static :: createException ( $ string , $ message , static :: INVALID_STRING_CONTAINS , $ propertyPath , $ constraints ) ; } }
Assert that string contains a sequence of chars .
57,092
static public function choice ( $ value , array $ choices , $ message = null , $ propertyPath = null ) { if ( ! Arrays :: in ( $ value , $ choices , true ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not an element of the valid values: %s' , static :: stringify ( $ value ) , implode ( ", " , array_map ( 'Assert\Assertion::stringify' , $ choices ) ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_CHOICE , $ propertyPath , array ( 'choices' => $ choices ) ) ; } }
Assert that value is in array of choices .
57,093
static public function numeric ( $ value , $ message = null , $ propertyPath = null ) { if ( ! is_numeric ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not numeric.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_NUMERIC , $ propertyPath ) ; } }
Assert that value is numeric .
57,094
static public function isArray ( $ value , $ message = null , $ propertyPath = null ) { if ( ! Arrays :: is ( $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not an array.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_ARRAY , $ propertyPath ) ; } }
Assert that value is array .
57,095
static public function keyExists ( $ value , $ key , $ message = null , $ propertyPath = null ) { static :: isArray ( $ value ) ; if ( ! Arrays :: exists ( $ key , $ value ) ) { $ message = $ message ? : sprintf ( 'Array does not contain an element with key "%s"' , static :: stringify ( $ key ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_KEY_EXISTS , $ propertyPath , array ( 'key' => $ key ) ) ; } }
Assert that key exists in array
57,096
static public function notEmptyKey ( $ value , $ key , $ message = null , $ propertyPath = null ) { static :: keyExists ( $ value , $ key , $ message , $ propertyPath ) ; static :: notEmpty ( $ value [ $ key ] , $ message , $ propertyPath ) ; }
Assert that key exists in array and it s value not empty .
57,097
static public function notBlank ( $ value , $ message = null , $ propertyPath = null ) { if ( false === $ value || ( empty ( $ value ) && '0' != $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is blank, but was expected to contain a value.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_NOT_BLANK , $ propertyPath ) ; } }
Assert that value is not blank
57,098
static public function isInstanceOf ( $ value , $ className , $ message = null , $ propertyPath = null ) { if ( ! ( $ value instanceof $ className ) ) { $ message = $ message ? : sprintf ( 'Class "%s" was expected to be instanceof of "%s" but is not.' , static :: stringify ( $ value ) , $ className ) ; throw static :: createException ( $ value , $ message , static :: INVALID_INSTANCE_OF , $ propertyPath , array ( 'class' => $ className ) ) ; } }
Assert that value is instance of given class - name .
57,099
static public function notIsInstanceOf ( $ value , $ className , $ message = null , $ propertyPath = null ) { if ( $ value instanceof $ className ) { $ message = $ message ? : sprintf ( 'Class "%s" was not expected to be instanceof of "%s".' , static :: stringify ( $ value ) , $ className ) ; throw static :: createException ( $ value , $ message , static :: INVALID_NOT_INSTANCE_OF , $ propertyPath , array ( 'class' => $ className ) ) ; } }
Assert that value is not instance of given class - name .