idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
52,000
protected function wheresToSubquery ( SearchableSubquery $ subquery ) { $ bindingKey = 0 ; $ typesToMove = [ 'basic' , 'in' , 'notin' , 'between' , 'null' , 'notnull' , 'date' , 'day' , 'month' , 'year' , ] ; foreach ( ( array ) $ this -> query -> wheres as $ key => $ where ) { $ type = strtolower ( $ where [ 'type' ] ...
Move where clauses to subquery to improve performance .
52,001
protected function countBindings ( array $ where , $ type ) { if ( $ this -> isHasWhere ( $ where , $ type ) ) { return substr_count ( $ where [ 'column' ] . $ where [ 'value' ] , '?' ) ; } elseif ( $ type === 'basic' ) { return ( int ) ! $ where [ 'value' ] instanceof Expression ; } elseif ( in_array ( $ type , [ 'bas...
Get number of bindings provided for a where clause .
52,002
protected function buildCase ( Column $ column , array $ words ) { $ operator = $ this -> getLikeOperator ( ) ; $ bindings [ 'select' ] = $ bindings [ 'where' ] = array_map ( function ( $ word ) { return $ this -> caseBinding ( $ word ) ; } , $ words ) ; $ case = $ this -> buildEqualsCase ( $ column , $ words ) ; if ( ...
Build case clause from all words for a single column .
52,003
protected function buildEqualsCase ( Column $ column , array $ words ) { $ equals = implode ( ' or ' , array_fill ( 0 , count ( $ words ) , sprintf ( '%s = ?' , $ column -> getWrapped ( ) ) ) ) ; $ score = 15 * $ column -> getWeight ( ) ; return "case when {$equals} then {$score} else 0 end" ; }
Build basic search case for equals comparison .
52,004
protected function joinForSearch ( $ mappings , $ subquery ) { $ mappings = is_array ( $ mappings ) ? $ mappings : ( array ) $ mappings ; $ columns = new ColumnCollection ; $ grammar = $ this -> query -> getGrammar ( ) ; $ joiner = static :: $ joinerFactory -> make ( $ subquery -> getQuery ( ) , $ this -> model ) ; for...
Join related tables on the search subquery .
52,005
public function prefixColumnsForJoin ( ) { if ( ! $ columns = $ this -> query -> columns ) { return $ this -> select ( $ this -> model -> getTable ( ) . '.*' ) ; } foreach ( $ columns as $ key => $ column ) { if ( $ this -> model -> hasColumn ( $ column ) ) { $ columns [ $ key ] = $ this -> model -> getTable ( ) . '.' ...
Prefix selected columns with table name in order to avoid collisions .
52,006
public function leftJoinRelations ( $ relations ) { $ relations = is_array ( $ relations ) ? $ relations : func_get_args ( ) ; return $ this -> joinRelations ( $ relations , 'left' ) ; }
Left join related tables .
52,007
public function rightJoinRelations ( $ relations ) { $ relations = is_array ( $ relations ) ? $ relations : func_get_args ( ) ; return $ this -> joinRelations ( $ relations , 'right' ) ; }
Right join related tables .
52,008
protected function isWhereNullByArgs ( ArgumentBag $ args ) { return is_null ( $ args -> get ( 'operator' ) ) || is_null ( $ args -> get ( 'value' ) ) && ! in_array ( $ args -> get ( 'operator' ) , [ '<>' , '!=' ] ) ; }
Determine whether where is a whereNull by the arguments passed to where method .
52,009
protected function extractColumnAlias ( $ column ) { $ alias = $ column ; if ( strpos ( $ column , ' as ' ) !== false ) { list ( $ column , $ alias ) = explode ( ' as ' , $ column ) ; } return [ $ column , $ alias ] ; }
Extract real name and alias from the sql select clause .
52,010
public function parseMappedColumn ( $ mapping ) { $ segments = explode ( '.' , $ mapping ) ; $ column = array_pop ( $ segments ) ; $ target = implode ( '.' , $ segments ) ; return [ $ target , $ column ] ; }
Get the target relation and column from the mapping .
52,011
protected static function loadColumnListing ( ) { if ( empty ( static :: $ columnListing ) ) { $ instance = new static ; static :: $ columnListing = $ instance -> getConnection ( ) -> getSchemaBuilder ( ) -> getColumnListing ( $ instance -> getTable ( ) ) ; } }
Fetch model table columns .
52,012
public static function make ( $ query , Model $ model = null ) { if ( $ query instanceof EloquentBuilder ) { $ model = $ query -> getModel ( ) ; $ query = $ query -> getQuery ( ) ; } return new Joiner ( $ query , $ model ) ; }
Create new joiner instance .
52,013
protected function getJoinClause ( Model $ parent , Relation $ relation , $ table , $ type ) { list ( $ fk , $ pk ) = $ this -> getJoinKeys ( $ relation ) ; $ join = ( new Join ( $ this -> query , $ type , $ table ) ) -> on ( $ fk , '=' , $ pk ) ; if ( in_array ( SoftDeletes :: class , class_uses_recursive ( $ relation...
Get the join clause for related table .
52,014
protected function joinIntermediate ( Model $ parent , Relation $ relation , $ type ) { if ( $ relation instanceof BelongsToMany ) { $ table = $ relation -> getTable ( ) ; $ fk = $ relation -> getQualifiedForeignPivotKeyName ( ) ; } else { $ table = $ relation -> getParent ( ) -> getTable ( ) ; $ fk = $ relation -> get...
Join pivot or through table .
52,015
protected function getJoinKeys ( Relation $ relation ) { if ( $ relation instanceof MorphTo ) { throw new LogicException ( "MorphTo relation cannot be joined." ) ; } if ( $ relation instanceof HasOneOrMany ) { return [ $ relation -> getQualifiedForeignKeyName ( ) , $ relation -> getQualifiedParentKeyName ( ) ] ; } if (...
Get pair of the keys from relation in order to join the table .
52,016
public static function getTasa ( $ codigo ) { if ( isset ( self :: $ impuestos [ $ codigo ] [ 'tasa' ] ) ) return self :: $ impuestos [ $ codigo ] [ 'tasa' ] ; return false ; }
Entrega la pasa del impuesto adicional
52,017
public static function getGlosa ( $ tag ) { if ( ! isset ( self :: $ tablas [ $ tag ] ) ) return false ; return is_array ( self :: $ tablas [ $ tag ] ) ? self :: $ tablas [ $ tag ] [ 'glosa' ] : self :: $ tablas [ $ tag ] ; }
Entrega la glosa para el campo en la tabla
52,018
public static function getValor ( $ tag , $ codigo ) { if ( ! isset ( self :: $ tablas [ $ tag ] ) ) return false ; if ( ! is_array ( self :: $ tablas [ $ tag ] ) ) return $ codigo ; $ tabla = isset ( self :: $ tablas [ $ tag ] [ 'valor' ] ) ? self :: $ tablas [ $ tag ] [ 'valor' ] : self :: $ tablas [ self :: $ tablas...
Entrega el valor traducido a partir de la tabla
52,019
public static function read ( $ archivo , $ separador = ';' , $ delimitadortexto = '"' ) { if ( ( $ handle = fopen ( $ archivo , 'r' ) ) !== FALSE ) { $ data = array ( ) ; $ i = 0 ; while ( ( $ row = fgetcsv ( $ handle , 0 , $ separador , $ delimitadortexto ) ) !== FALSE ) { $ j = 0 ; foreach ( $ row as & $ col ) { $ d...
Lee un archivo CSV
52,020
public static function generate ( array $ data , $ archivo , $ separador = ';' , $ delimitadortexto = '"' ) { ob_clean ( ) ; header ( 'Content-type: text/csv' ) ; header ( 'Content-Disposition: attachment; filename=' . $ archivo . '.csv' ) ; header ( 'Pragma: no-cache' ) ; header ( 'Expires: 0' ) ; foreach ( $ data as ...
Crea un archivo CSV a partir de un arreglo
52,021
private function getTableCellWidth ( $ total , $ cells ) { $ widths = [ ] ; if ( is_int ( $ cells ) ) { $ width = floor ( $ total / $ cells ) ; for ( $ i = 0 ; $ i < $ cells ; ++ $ i ) { $ widths [ ] = $ width ; } } else if ( is_array ( $ cells ) ) { $ width = floor ( $ total / count ( $ cells ) ) ; foreach ( $ cells a...
Obtener el ancho de las columnas de una tabla
52,022
public function addTableWithoutEmptyCols ( $ titles , $ data , $ options = [ ] , $ html = true ) { $ cols_empty = [ ] ; foreach ( $ data as $ row ) { foreach ( $ row as $ col => $ value ) { if ( empty ( $ value ) ) { if ( ! array_key_exists ( $ col , $ cols_empty ) ) $ cols_empty [ $ col ] = 0 ; $ cols_empty [ $ col ] ...
Agregar una tabla al PDF removiendo aquellas columnas donde no existen datos en la columna para todas las filas
52,023
public static function rmdir ( $ dir ) { $ dir_content = scandir ( $ dir ) ; if ( $ dir_content !== false ) { foreach ( $ dir_content as & $ entry ) { if ( ! in_array ( $ entry , array ( '.' , '..' ) ) ) { $ entry = $ dir . DIRECTORY_SEPARATOR . $ entry ; if ( ! is_dir ( $ entry ) ) { unlink ( $ entry ) ; } else { self...
Borra recursivamente un directorio
52,024
private static function buildClient ( array $ config = [ ] ) : GuzzleClient { $ handlerStack = new HandlerStack ( \ GuzzleHttp \ choose_handler ( ) ) ; $ handlerStack -> push ( Middleware :: prepareBody ( ) , 'prepare_body' ) ; $ config = array_merge ( [ 'handler' => $ handlerStack ] , $ config ) ; return new GuzzleCli...
Build the Guzzle client instance .
52,025
public function run ( $ outputFile = '/dev/null' , $ append = false ) { if ( $ this -> command === null ) { return ; } switch ( $ this -> getOS ( ) ) { case self :: OS_WINDOWS : shell_exec ( sprintf ( '%s &' , $ this -> command , $ outputFile ) ) ; break ; case self :: OS_NIX : $ this -> pid = ( int ) shell_exec ( spri...
Runs the command in a background process .
52,026
public function isRunning ( ) { $ this -> checkSupportingOS ( 'Cocur\BackgroundProcess can only check if a process is running on *nix-based ' . 'systems, such as Unix, Linux or Mac OS X. You are running "%s".' ) ; try { $ result = shell_exec ( sprintf ( 'ps %d 2>&1' , $ this -> pid ) ) ; if ( count ( preg_split ( "/\n/...
Returns if the process is currently running .
52,027
protected function getIdentifier ( $ reference , $ uow ) { if ( ! $ this -> hasIdentifier ( $ reference ) ) { $ class = $ this -> manager -> getClassMetadata ( get_class ( $ reference ) ) ; return $ class -> getIdentifierValues ( $ reference ) ; } if ( method_exists ( $ uow , 'getEntityIdentifier' ) ) { return $ uow ->...
Get identifier for a unit of work
52,028
private function hasIdentifier ( $ reference ) { $ uow = $ this -> manager -> getUnitOfWork ( ) ; if ( $ this -> manager instanceof PhpcrDocumentManager ) { return $ uow -> contains ( $ reference ) ; } else { return $ uow -> isInIdentityMap ( $ reference ) ; } }
Checks if object has identifier already in unit of work .
52,029
public function load ( ObjectManager $ manager , FixtureInterface $ fixture ) { if ( $ this -> logger ) { $ prefix = '' ; if ( $ fixture instanceof OrderedFixtureInterface ) { $ prefix = sprintf ( '[%d] ' , $ fixture -> getOrder ( ) ) ; } $ this -> log ( 'loading ' . $ prefix . get_class ( $ fixture ) ) ; } if ( $ fixt...
Load a fixture with the given persistence manager .
52,030
public function purge ( ) { if ( $ this -> purger === null ) { throw new \ Exception ( 'Doctrine\Common\DataFixtures\Purger\PurgerInterface instance is required if you want to purge the database before loading your data fixtures.' ) ; } if ( $ this -> logger ) { $ this -> log ( 'purging database' ) ; } $ this -> purger...
Purges the database before loading .
52,031
public function loadFromFile ( $ fileName ) { if ( ! is_readable ( $ fileName ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" does not exist or is not readable' , $ fileName ) ) ; } $ iterator = new \ ArrayIterator ( [ new \ SplFileInfo ( $ fileName ) ] ) ; return $ this -> loadFromIterator ( $ iterator ) ...
Find fixtures classes in a given file and load them .
52,032
public function getFixture ( $ className ) { if ( ! isset ( $ this -> fixtures [ $ className ] ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a registered fixture' , $ className ) ) ; } return $ this -> fixtures [ $ className ] ; }
Get a specific fixture instance
52,033
public function sort ( ) { foreach ( $ this -> nodeList as $ definition ) { if ( $ definition -> state !== Vertex :: NOT_VISITED ) { continue ; } $ this -> visit ( $ definition ) ; } $ sortedList = $ this -> sortedNodeList ; $ this -> nodeList = [ ] ; $ this -> sortedNodeList = [ ] ; return $ sortedList ; }
Return a valid order list of all current nodes . The desired topological sorting is the postorder of these searches .
52,034
protected function getRealClass ( $ className ) { if ( Version :: compare ( '2.2.0' ) <= 0 ) { return ClassUtils :: getRealClass ( $ className ) ; } if ( substr ( $ className , - 5 ) === 'Proxy' ) { return substr ( $ className , 0 , - 5 ) ; } return $ className ; }
Get real class name of a reference that could be a proxy
52,035
public function serialize ( ) { $ unitOfWork = $ this -> getManager ( ) -> getUnitOfWork ( ) ; $ simpleReferences = [ ] ; foreach ( $ this -> getReferences ( ) as $ name => $ reference ) { $ className = $ this -> getRealClass ( get_class ( $ reference ) ) ; $ simpleReferences [ $ name ] = [ $ className , $ this -> getI...
Serialize reference repository
52,036
public function unserialize ( $ serializedData ) { $ repositoryData = json_decode ( $ serializedData , true ) ; $ references = $ repositoryData [ 'references' ] ; foreach ( $ references as $ name => $ proxyReference ) { $ this -> setReference ( $ name , $ this -> getManager ( ) -> getReference ( $ proxyReference [ 0 ] ...
Unserialize reference repository
52,037
public function load ( $ baseCacheName ) { $ filename = $ baseCacheName . '.ser' ; if ( ! file_exists ( $ filename ) || ( $ serializedData = file_get_contents ( $ filename ) ) === false ) { return false ; } $ this -> unserialize ( $ serializedData ) ; return true ; }
Load data fixture reference repository
52,038
public static function ctype_alnum ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^A-Za-z0-9]/' , $ text ) ; }
Returns TRUE if every character in text is either a letter or a digit FALSE otherwise .
52,039
public static function ctype_alpha ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^A-Za-z]/' , $ text ) ; }
Returns TRUE if every character in text is a letter FALSE otherwise .
52,040
public static function ctype_cntrl ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^\x00-\x1f\x7f]/' , $ text ) ; }
Returns TRUE if every character in text is a control character from the current locale FALSE otherwise .
52,041
public static function ctype_digit ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^0-9]/' , $ text ) ; }
Returns TRUE if every character in the string text is a decimal digit FALSE otherwise .
52,042
public static function ctype_lower ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^a-z]/' , $ text ) ; }
Returns TRUE if every character in text is a lowercase letter .
52,043
public static function ctype_punct ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^!-\/\:-@\[-`\{-~]/' , $ text ) ; }
Returns TRUE if every character in text is printable but neither letter digit or blank FALSE otherwise .
52,044
public static function ctype_space ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^\s]/' , $ text ) ; }
Returns TRUE if every character in text creates some sort of white space FALSE otherwise . Besides the blank character this also includes tab vertical tab line feed carriage return and form feed characters .
52,045
public static function ctype_upper ( $ text ) { $ text = self :: convert_int_to_char_for_ctype ( $ text ) ; return \ is_string ( $ text ) && '' !== $ text && ! preg_match ( '/[^A-Z]/' , $ text ) ; }
Returns TRUE if every character in text is an uppercase letter .
52,046
private static function convert_int_to_char_for_ctype ( $ int ) { if ( ! \ is_int ( $ int ) ) { return $ int ; } if ( $ int < - 128 || $ int > 255 ) { return ( string ) $ int ; } if ( $ int < 0 ) { $ int += 256 ; } return \ chr ( $ int ) ; }
Converts integers to their char versions according to normal ctype behaviour if needed .
52,047
public function get ( $ key ) { if ( ! isset ( $ this -> hashmap [ $ key ] ) ) { return null ; } $ node = $ this -> hashmap [ $ key ] ; if ( count ( $ this -> hashmap ) == 1 ) { return $ node -> getData ( ) ; } $ this -> detach ( $ node ) ; $ this -> attach ( $ this -> head , $ node ) ; return $ node -> getData ( ) ; }
Get an element with the given key
52,048
public function put ( $ key , $ data ) { if ( $ this -> capacity <= 0 ) { return false ; } if ( isset ( $ this -> hashmap [ $ key ] ) && ! empty ( $ this -> hashmap [ $ key ] ) ) { $ node = $ this -> hashmap [ $ key ] ; $ this -> detach ( $ node ) ; $ this -> attach ( $ this -> head , $ node ) ; $ node -> setData ( $ d...
Inserts a new element into the cache
52,049
public function remove ( $ key ) { if ( ! isset ( $ this -> hashmap [ $ key ] ) ) { return false ; } $ nodeToRemove = $ this -> hashmap [ $ key ] ; $ this -> detach ( $ nodeToRemove ) ; unset ( $ this -> hashmap [ $ nodeToRemove -> getKey ( ) ] ) ; return true ; }
Removes a key from the cache
52,050
private function attach ( $ head , $ node ) { $ node -> setPrevious ( $ head ) ; $ node -> setNext ( $ head -> getNext ( ) ) ; $ node -> getNext ( ) -> setPrevious ( $ node ) ; $ node -> getPrevious ( ) -> setNext ( $ node ) ; }
Adds a node to the head of the list
52,051
private function detach ( $ node ) { $ node -> getPrevious ( ) -> setNext ( $ node -> getNext ( ) ) ; $ node -> getNext ( ) -> setPrevious ( $ node -> getPrevious ( ) ) ; }
Removes a node from the list
52,052
protected function createFixture ( $ class ) : FixtureInterface { if ( ! isset ( $ this -> loadedFixtures [ $ class ] ) ) { throw new LogicException ( sprintf ( 'The "%s" fixture class is trying to be loaded, but is not available. Make sure this class is defined as a service and tagged with "%s".' , $ class , FixturesC...
Overridden to not allow new fixture classes to be instantiated .
52,053
private function addGroupsFixtureMapping ( string $ className , array $ groups ) : void { foreach ( $ groups as $ group ) { $ this -> groupsFixtureMapping [ $ group ] [ $ className ] = true ; } }
Generates an array of the groups and their fixtures
52,054
public function getReflector ( ) { if ( $ this -> reflector === null ) { $ this -> reflector = new ReflectionClosure ( $ this -> closure , $ this -> code ) ; $ this -> code = null ; } return $ this -> reflector ; }
Get the reflector for closure
52,055
function get_human_friendly ( $ name = null ) { if ( ! isset ( $ name ) ) { $ name = $ this -> post_type_name ; } return ucwords ( strtolower ( str_replace ( "-" , " " , str_replace ( "_" , " " , $ name ) ) ) ) ; }
Get human friendly
52,056
function register_exisiting_taxonomies ( ) { if ( is_array ( $ this -> exisiting_taxonomies ) ) { foreach ( $ this -> exisiting_taxonomies as $ taxonomy_name ) { register_taxonomy_for_object_type ( $ taxonomy_name , $ this -> post_type_name ) ; } } }
Register Exisiting Taxonomies
52,057
function populate_admin_columns ( $ column , $ post_id ) { global $ post ; switch ( $ column ) { case ( taxonomy_exists ( $ column ) ) : $ terms = get_the_terms ( $ post_id , $ column ) ; if ( ! empty ( $ terms ) ) { $ output = array ( ) ; foreach ( $ terms as $ term ) { $ output [ ] = sprintf ( '<a href="%s">%s</a>' ,...
Populate admin columns
52,058
function add_taxonomy_filters ( ) { global $ typenow ; global $ wp_query ; if ( $ typenow == $ this -> post_type_name ) { if ( is_array ( $ this -> filters ) ) { $ filters = $ this -> filters ; } else { $ filters = $ this -> taxonomies ; } if ( ! empty ( $ filters ) ) { foreach ( $ filters as $ tax_slug ) { $ tax = get...
Add taxtonomy filters
52,059
function make_columns_sortable ( $ columns ) { foreach ( $ this -> sortable as $ column => $ values ) { $ sortable_columns [ $ column ] = $ values [ 0 ] ; } $ columns = array_merge ( $ sortable_columns , $ columns ) ; return $ columns ; }
Make columns sortable
52,060
function menu_icon ( $ icon = "dashicons-admin-page" ) { if ( is_string ( $ icon ) && stripos ( $ icon , "dashicons" ) !== false ) { $ this -> options [ "menu_icon" ] = $ icon ; } else { $ this -> options [ "menu_icon" ] = "dashicons-admin-page" ; } }
Set menu icon
52,061
function bulk_updated_messages ( $ bulk_messages , $ bulk_counts ) { $ singular = $ this -> singular ; $ plural = $ this -> plural ; $ bulk_messages [ $ this -> post_type_name ] = array ( 'updated' => _n ( '%s ' . $ singular . ' updated.' , '%s ' . $ plural . ' updated.' , $ bulk_counts [ 'updated' ] ) , 'locked' => _n...
Bulk updated messages
52,062
public function createForNamespace ( $ namespace , $ fileContents ) { $ namespace = trim ( $ namespace , '\\' ) ; $ useStatements = [ ] ; $ currentNamespace = '' ; $ tokens = new \ ArrayIterator ( token_get_all ( $ fileContents ) ) ; while ( $ tokens -> valid ( ) ) { switch ( $ tokens -> current ( ) [ 0 ] ) { case T_NA...
Build a Context for a namespace in the provided file contents .
52,063
private function parseNamespace ( \ ArrayIterator $ tokens ) { $ this -> skipToNextStringOrNamespaceSeparator ( $ tokens ) ; $ name = '' ; while ( $ tokens -> valid ( ) && ( $ tokens -> current ( ) [ 0 ] === T_STRING || $ tokens -> current ( ) [ 0 ] === T_NS_SEPARATOR ) ) { $ name .= $ tokens -> current ( ) [ 1 ] ; $ t...
Deduce the name from tokens when we are at the T_NAMESPACE token .
52,064
private function resolveSingleType ( $ type , Context $ context ) { switch ( true ) { case $ this -> isKeyword ( $ type ) : return $ this -> resolveKeyword ( $ type ) ; case $ this -> isTypedArray ( $ type ) : return $ this -> resolveTypedArray ( $ type , $ context ) ; case $ this -> isFqsen ( $ type ) : return $ this ...
resolve the given type into a type object
52,065
public function addKeyword ( $ keyword , $ typeClassName ) { if ( ! class_exists ( $ typeClassName ) ) { throw new \ InvalidArgumentException ( 'The Value Object that needs to be created with a keyword "' . $ keyword . '" must be an existing class' . ' but we could not find the class ' . $ typeClassName ) ; } if ( ! in...
Adds a keyword to the list of Keywords and associates it with a specific Value Object .
52,066
private function resolveTypedObject ( $ type , Context $ context = null ) { return new Object_ ( $ this -> fqsenResolver -> resolve ( $ type , $ context ) ) ; }
Resolves the given FQSEN string into an FQSEN object .
52,067
private function resolveCollection ( \ ArrayIterator $ tokens , Type $ classType , Context $ context ) { $ isArray = ( 'array' === ( string ) $ classType ) ; if ( ! $ isArray && ( ! $ classType instanceof Object_ || $ classType -> getFqsen ( ) === null ) ) { throw new \ RuntimeException ( $ classType . ' is not a colle...
Resolves the collection values and keys
52,068
public static function fromValue ( $ value , $ noneValue = null ) { if ( $ value === $ noneValue ) { return None :: create ( ) ; } return new Some ( $ value ) ; }
Creates an option given a return value .
52,069
public static function fromReturn ( $ callback , array $ arguments = array ( ) , $ noneValue = null ) { return new LazyOption ( function ( ) use ( $ callback , $ arguments , $ noneValue ) { $ return = call_user_func_array ( $ callback , $ arguments ) ; if ( $ return === $ noneValue ) { return None :: create ( ) ; } ret...
Creates a lazy - option with the given callback .
52,070
public function isExpired ( ) { $ payload = $ this -> getPayload ( ) ; if ( isset ( $ payload [ 'exp' ] ) ) { $ now = new \ DateTime ( 'now' ) ; if ( is_int ( $ payload [ 'exp' ] ) ) { return ( $ now -> getTimestamp ( ) - $ payload [ 'exp' ] ) > 0 ; } if ( is_numeric ( $ payload [ 'exp' ] ) ) { return ( $ now -> format...
Checks whether the token is expired based on the exp value . it .
52,071
public function sign ( $ key , $ password = null ) { $ this -> signature = $ this -> getSigner ( ) -> sign ( $ this -> generateSigninInput ( ) , $ key , $ password ) ; $ this -> isSigned = true ; return $ this -> signature ; }
Signs the JWS signininput .
52,072
public function getTokenString ( ) { $ signinInput = $ this -> generateSigninInput ( ) ; return sprintf ( '%s.%s' , $ signinInput , $ this -> encoder -> encode ( $ this -> getSignature ( ) ) ) ; }
Returns the string representing the JWT .
52,073
public static function load ( $ jwsTokenString , $ allowUnsecure = false , Encoder $ encoder = null , $ encryptionEngine = 'OpenSSL' ) { if ( $ encoder === null ) { $ encoder = strpbrk ( $ jwsTokenString , '+/=' ) ? new Base64Encoder ( ) : new Base64UrlSafeEncoder ( ) ; } $ parts = explode ( '.' , $ jwsTokenString ) ; ...
Creates an instance of a JWS from a JWT .
52,074
private function getSigninInput ( ) { $ parts = explode ( '.' , $ this -> originalToken ) ; if ( count ( $ parts ) >= 2 ) { return sprintf ( '%s.%s' , $ parts [ 0 ] , $ parts [ 1 ] ) ; } return $ this -> generateSigninInput ( ) ; }
Get the original token signin input if it exists otherwise generate the signin input for the current JWS
52,075
public function generateSigninInput ( ) { $ base64payload = $ this -> encoder -> encode ( json_encode ( $ this -> getPayload ( ) , JSON_UNESCAPED_SLASHES ) ) ; $ base64header = $ this -> encoder -> encode ( json_encode ( $ this -> getHeader ( ) , JSON_UNESCAPED_SLASHES ) ) ; return sprintf ( '%s.%s' , $ base64header , ...
Generates the signininput for the current JWT .
52,076
public function verify ( $ key , $ signature , $ input ) { $ signedInput = $ this -> sign ( $ input , $ key ) ; return $ this -> timingSafeEquals ( $ signedInput , $ signature ) ; }
To prevent timing attacks we are using PHP 5 . 6 native function hash_equals in case of PHP < 5 . 6 a timing safe equals comparison function .
52,077
protected function getKeyResource ( $ key , $ password = null ) { if ( is_resource ( $ key ) ) { return $ key ; } $ resource = openssl_pkey_get_public ( $ key ) ? : openssl_pkey_get_private ( $ key , $ password ) ; if ( $ resource === false ) { throw new RuntimeException ( 'Could not read key resource: ' . openssl_erro...
Converts a string representation of a key into an OpenSSL resource .
52,078
protected function supportsKey ( $ key ) { $ keyDetails = openssl_pkey_get_details ( $ key ) ; return isset ( $ keyDetails [ 'type' ] ) ? $ this -> getSupportedPrivateKeyType ( ) === $ keyDetails [ 'type' ] : false ; }
Check if the key is supported by this signer .
52,079
public static function isTruthy ( $ value ) { if ( ! $ value ) { return $ value === 0 || $ value === '0' ; } elseif ( $ value instanceof \ stdClass ) { return ( bool ) get_object_vars ( $ value ) ; } else { return true ; } }
Returns true if the value is truthy
52,080
public static function isArray ( $ value ) { if ( is_array ( $ value ) ) { return ! $ value || array_keys ( $ value ) [ 0 ] === 0 ; } return $ value instanceof \ Countable && $ value instanceof \ ArrayAccess ? count ( $ value ) == 0 || $ value -> offsetExists ( 0 ) : false ; }
Determine if the provided value is a JMESPath compatible array .
52,081
public static function isEqual ( $ a , $ b ) { if ( $ a === $ b ) { return true ; } elseif ( $ a instanceof \ stdClass ) { return self :: isEqual ( ( array ) $ a , $ b ) ; } elseif ( $ b instanceof \ stdClass ) { return self :: isEqual ( $ a , ( array ) $ b ) ; } else { return false ; } }
JSON aware value comparison function .
52,082
public static function slice ( $ value , $ start = null , $ stop = null , $ step = 1 ) { if ( ! is_array ( $ value ) && ! is_string ( $ value ) ) { throw new \ InvalidArgumentException ( 'Expects string or array' ) ; } return self :: sliceIndices ( $ value , $ start , $ stop , $ step ) ; }
Creates a Python - style slice of a string or array .
52,083
public function reverse ( ) { return new Complex ( $ this -> imaginaryPart , $ this -> realPart , ( $ this -> realPart == 0.0 ) ? null : $ this -> suffix ) ; }
Returns the reverse of this complex number
52,084
public function manualItemUpdate ( string $ accessKey , int $ itemId , string $ server ) { return Guzzle :: get ( "/private/market/item/update" , [ RequestOptions :: QUERY => [ 'access' => $ accessKey , 'item_id' => $ itemId , 'server' => $ server , ] ] ) ; }
Request an item to be updated
52,085
private static function setClient ( ) { if ( self :: $ client === null ) { self :: $ client = new Client ( [ 'base_uri' => self :: $ environment , 'timeout' => self :: TIMEOUT , 'verify' => self :: VERIFY , ] ) ; } }
Set the Guzzle client
52,086
private function processEventNotificationLogRecord ( array $ records , $ currentRecordIndex ) { $ record = $ records [ $ currentRecordIndex ] ; $ record [ 'message' ] = null ; $ record [ 'channel' ] = '_event_notify' ; $ record [ 'context' ] = array ( $ record [ 'context' ] [ 'event' ] => $ record [ 'context' ] [ 'list...
In Symfony applications is common to have lots of consecutive event notify log messages . This method combines them all to generate a more compact output .
52,087
private function processStringPlaceholders ( $ string , array $ variables ) { foreach ( $ variables as $ key => $ value ) { if ( ! is_string ( $ value ) && ! is_numeric ( $ value ) && ! is_bool ( $ value ) ) { continue ; } $ string = str_replace ( '{' . $ key . '}' , $ value , ( string ) $ string ) ; } return $ string ...
It interpolates the given string replacing its placeholders with the values defined in the given variables array .
52,088
private function processTranslationLogRecord ( array $ records , $ currentRecordIndex ) { $ record = $ records [ $ currentRecordIndex ] ; if ( isset ( $ records [ $ currentRecordIndex - 1 ] ) && $ this -> isTranslationLog ( $ records [ $ currentRecordIndex - 1 ] ) ) { $ record [ '_properties' ] [ 'display_log_info' ] =...
In Symfony applications is common to have lots of consecutive translation not found log messages . This method combines them all to generate a more compact output .
52,089
private function formatThrowableObjects ( array $ array ) { array_walk_recursive ( $ array , function ( & $ value ) { if ( $ value instanceof \ Throwable ) { try { $ value = serialize ( $ value ) ; } catch ( \ Throwable $ throwable ) { $ value = $ this -> formatThrowable ( $ value ) ; } } } ) ; return $ array ; }
Turns any Throwable object present in the given array into a string representation . If the object cannot be serialized an approximative representation of the object is given instead .
52,090
private function formatTextBlock ( $ text , $ prefix = '' , $ prefixAllLines = false ) { if ( empty ( $ text ) ) { return $ text ; } $ textLines = explode ( PHP_EOL , $ text ) ; $ addTrailingNewline = false ; if ( '' === $ textLines [ count ( $ textLines ) - 1 ] ) { array_pop ( $ textLines ) ; $ addTrailingNewline = tr...
Prepends the prefix to every line of the given string .
52,091
private function getInlineLevel ( array $ record ) { if ( $ this -> isTranslationLog ( $ record ) ) { return 0 ; } if ( $ this -> isDoctrineLog ( $ record ) || $ this -> isAsseticLog ( $ record ) ) { return 1 ; } return 2 ; }
It returns the level at which YAML component inlines the values which determines how compact or readable the information is displayed .
52,092
public static function find ( ) { try { $ client = static :: findOneByType ( ClientInterface :: class ) ; } catch ( DiscoveryFailedException $ e ) { throw new \ Http \ Discovery \ Exception \ NotFoundException ( 'No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example...
Finds a PSR - 18 HTTP Client .
52,093
protected static function findOneByType ( $ type ) { if ( null !== ( $ class = self :: getFromCache ( $ type ) ) ) { return $ class ; } $ exceptions = [ ] ; foreach ( self :: $ strategies as $ strategy ) { try { $ candidates = call_user_func ( $ strategy . '::getCandidates' , $ type ) ; } catch ( StrategyUnavailableExc...
Finds a class .
52,094
protected static function evaluateCondition ( $ condition ) { if ( is_string ( $ condition ) ) { return self :: safeClassExists ( $ condition ) ; } if ( is_callable ( $ condition ) ) { return ( bool ) $ condition ( ) ; } if ( is_bool ( $ condition ) ) { return $ condition ; } if ( is_array ( $ condition ) ) { foreach (...
Evaluates conditions to boolean .
52,095
public static function find ( ) { try { $ uriFactory = static :: findOneByType ( UriFactory :: class ) ; } catch ( DiscoveryFailedException $ e ) { throw new NotFoundException ( 'No uri factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.'...
Finds a URI Factory .
52,096
private static function getPuliDiscovery ( ) { if ( ! isset ( self :: $ puliDiscovery ) ) { $ factory = self :: getPuliFactory ( ) ; $ repository = $ factory -> createRepository ( ) ; self :: $ puliDiscovery = $ factory -> createDiscovery ( $ repository ) ; } return self :: $ puliDiscovery ; }
Returns the Puli discovery layer .
52,097
public static function setPuliFactory ( $ puliFactory ) { if ( ! is_callable ( [ $ puliFactory , 'createRepository' ] ) || ! is_callable ( [ $ puliFactory , 'createDiscovery' ] ) ) { throw new \ InvalidArgumentException ( 'The Puli Factory must expose a repository and a discovery' ) ; } self :: $ puliFactory = $ puliFa...
Sets the Puli factory .
52,098
public static function find ( ) { try { $ messageFactory = static :: findOneByType ( MessageFactory :: class ) ; } catch ( DiscoveryFailedException $ e ) { throw new NotFoundException ( 'No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message impl...
Finds a Message Factory .
52,099
public static function find ( ) { try { $ asyncClient = static :: findOneByType ( HttpAsyncClient :: class ) ; } catch ( DiscoveryFailedException $ e ) { throw new NotFoundException ( 'No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guz...
Finds an HTTP Async Client .