idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
228,600
public function replace ( $ find , $ with ) : Utility { $ replace = [ ] ; foreach ( $ this -> parameters ( $ find ) as $ parameter ) { $ replace [ ] = preg_quote ( $ parameter -> value ( ) ) ; } $ withString = new static ( $ with , $ this -> encoding ) ; $ string = preg_replace ( '#(' . implode ( '|' , $ replace ) . ')...
Replace occurrences in the string with a given value
228,601
public function replaceNonAlpha ( string $ replacement = '' , bool $ strict = false ) : Utility { if ( $ strict ) { $ pattern = '/[^a-zA-Z]/' ; } else { $ pattern = '/[^a-zA-Z ]/' ; } $ string = preg_replace ( $ pattern , $ replacement , trim ( $ this -> string ) ) ; return new static ( $ string , $ this -> encoding ) ...
Replace none alpha characters in the string with the given value
228,602
public function reverse ( ) : Utility { $ string = '' ; for ( $ i = $ this -> length ( ) - 1 ; $ i >= 0 ; $ i -- ) { $ string .= \ mb_substr ( $ this -> string , $ i , 1 , $ this -> encoding ) ; } return new static ( $ string , $ this -> encoding ) ; }
Reverse the string
228,603
public function surround ( $ with ) : Utility { $ surrounding = new static ( $ with , $ this -> encoding ) ; return new static ( implode ( '' , [ $ surrounding , $ this -> string , $ surrounding ] ) , $ this -> encoding ) ; }
Wrap the the string with a value
228,604
public function toCamelCase ( ) : Utility { $ string = preg_replace ( '/([a-z0-9])(?=[A-Z])/' , '$1 ' , $ this -> string ) ; $ words = preg_split ( '/[\W_]/' , $ string ) ; $ words = array_map ( function ( $ word ) { return ucfirst ( strtolower ( $ word ) ) ; } , $ words ) ; $ string = lcfirst ( implode ( '' , $ words ...
Transform the value to into camelCase format
228,605
public function toPascalCase ( ) : Utility { $ string = ucfirst ( $ this -> toCamelCase ( ) -> value ( ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to into PascalCase format
228,606
public function toSentence ( ) : Utility { $ sentences = preg_split ( '/([^\.\!\?;]+[\.\!\?;"]+)/' , $ this -> string , - 1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; $ sentences = array_map ( function ( $ sentence ) { $ sentence = trim ( $ sentence ) ; if ( ! ctype_upper ( $ sentence [ 0 ] ) ) { $ sentence =...
Turn the string into a sentence .
228,607
public function toSlug ( string $ separator = '-' ) : Utility { $ string = mb_convert_encoding ( $ this -> string , 'UTF-8' , $ this -> encoding ) ; $ string = preg_replace ( '/[^\s\p{L}0-9\-' . $ separator . ']/u' , '' , $ string ) ; $ string = htmlentities ( $ string , ENT_QUOTES , 'UTF-8' ) ; $ string = preg_replace...
Clean a string to only have alpha numeric characters turn spaces into a separator slug
228,608
public function toSlugUtf8 ( string $ separator = '-' ) : Utility { $ string = mb_convert_encoding ( $ this -> string , 'UTF-8' , $ this -> encoding ) ; $ string = preg_replace ( '/[^\s\p{L}0-9\-' . $ separator . ']/u' , '' , $ string ) ; $ string = preg_replace ( '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|s...
Same as toSlug but preserves UTF8 characters
228,609
public function toSnakeCase ( ) : Utility { $ string = mb_ereg_replace ( '\B([A-Z])' , '-\1' , trim ( $ this -> string ) ) ; $ string = mb_strtolower ( $ string , $ this -> encoding ) ; $ string = mb_ereg_replace ( '[-_\s]+' , '_' , $ string ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to snake_case format
228,610
public function toStudlyCase ( ) : Utility { $ string = implode ( ' ' , $ this -> prepareForCasing ( $ this -> string ) ) ; $ string = str_replace ( ' ' , '' , ucwords ( $ string ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to StudlyCase format
228,611
public function toTitleCase ( ) : Utility { $ words = explode ( ' ' , $ this -> string ) ; $ string = mb_convert_case ( implode ( ' ' , $ words ) , MB_CASE_TITLE , $ this -> encoding ( ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to into Title Case format
228,612
public function trim ( $ values = " \t\n\r\0\x0B" ) : Utility { $ parameters = $ this -> parameters ( $ values ) ; $ string = trim ( $ this -> string , implode ( '' , $ parameters ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Trim a collection of values from the string using trim
228,613
public function trimLeft ( $ values = " \t\n\r\0\x0B" ) : Utility { $ parameters = $ this -> parameters ( $ values ) ; $ string = ltrim ( $ this -> string , implode ( '' , $ parameters ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Trim a collection of values from the string using rtrim
228,614
public function trimRight ( $ values = " \t\n\r\0\x0B" ) : Utility { $ parameters = $ this -> parameters ( $ values ) ; $ string = rtrim ( $ this -> string , implode ( '' , $ parameters ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Trim a collection of values from the string using ltrim
228,615
public function alterColumn ( $ name , $ attrib , $ value ) { $ this -> requireColumn ( $ name ) ; $ newColumns = $ this -> _columns ; if ( $ attrib === null ) { unset ( $ newColumns [ $ name ] ) ; } else { $ newColumn = $ newColumns [ $ name ] -> toArray ( ) ; $ newColumn [ $ attrib ] = $ value ; $ newColumns [ $ name...
Internal method to alter a column
228,616
protected function _renameToTmp ( ) { $ tmpTableName = $ this -> _name ; $ tableNames = $ this -> _database -> getTableNames ( ) ; do { $ tmpTableName .= '_bak' ; } while ( in_array ( $ tmpTableName , $ tableNames ) ) ; $ tmpTableName = $ this -> _database -> quoteIdentifier ( $ tmpTableName ) ; $ this -> alter ( "RENA...
Rename table to a unique temporary name
228,617
public function dump ( array $ options = array ( ) ) { if ( ! class_exists ( 'zxf\Symfony\Component\Yaml\Dumper' ) ) { throw new RuntimeException ( 'Unable to dump the container as the Symfony Yaml Component is not installed.' ) ; } if ( null === $ this -> dumper ) { $ this -> dumper = new YmlDumper ( ) ; } return $ th...
Dumps the service container as an YAML string .
228,618
private function addServices ( ) { if ( ! $ this -> container -> getDefinitions ( ) ) { return '' ; } $ code = "services:\n" ; foreach ( $ this -> container -> getDefinitions ( ) as $ id => $ definition ) { $ code .= $ this -> addService ( $ id , $ definition ) ; } $ aliases = $ this -> container -> getAliases ( ) ; fo...
Adds services .
228,619
private function prepareParameters ( array $ parameters , $ escape = true ) { $ filtered = array ( ) ; foreach ( $ parameters as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = $ this -> prepareParameters ( $ value , $ escape ) ; } elseif ( $ value instanceof Reference || is_string ( $ value ) && 0 === str...
Prepares parameters .
228,620
public function render ( $ view , array $ data = null ) { foreach ( get_object_vars ( $ this ) as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> unguarded ) ) { $ this -> $ key = $ this -> scrub ( $ value ) ; } } $ data = $ this -> scrub ( $ data ) ; return parent :: render ( $ view , $ data ) ; }
Return our compiled view . Sanitize the data before rendering .
228,621
public function output ( $ view , array $ data = null ) { $ response = new Response ( $ this -> render ( $ view , $ data ) , Response :: HTTP_OK , [ 'Content-Type' => 'text/html' ] ) ; $ response -> send ( ) ; }
Output the content instead of just render .
228,622
public function scrub ( $ var ) { if ( is_string ( $ var ) ) { return $ this -> escape ( $ var ) ; } elseif ( is_array ( $ var ) ) { foreach ( $ var as $ key => $ value ) { if ( ! in_array ( ( string ) $ key , $ this -> unguarded ) ) { $ var [ $ key ] = $ this -> scrub ( $ value ) ; } } return $ var ; } elseif ( is_obj...
Recursively sanitize output .
228,623
public function unguard ( $ key ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k ) { $ this -> unguard ( $ k ) ; } } else { $ this -> unguarded [ ] = $ key ; } }
Don t escape template variables with the specified name .
228,624
public final function contains ( Rectangle $ rect ) : bool { return ( ( ( ( $ this -> point -> x <= $ rect -> point -> x ) && ( ( $ rect -> point -> x + $ rect -> size -> width ) <= ( $ this -> point -> x + $ this -> size -> width ) ) ) && ( $ this -> point -> y <= $ rect -> point -> y ) ) && ( ( $ rect -> point -> y +...
Returns if the current rectangle contains the defined rectangle .
228,625
public final function containsLocation ( $ xOrPoint , int $ y = null ) : bool { $ x = $ xOrPoint ; if ( $ x instanceof Point ) { $ y = $ x -> y ; $ x = $ x -> x ; } else if ( \ is_integer ( $ xOrPoint ) ) { $ x = $ xOrPoint ; } else if ( TypeTool :: IsInteger ( $ xOrPoint ) ) { $ x = \ intval ( $ xOrPoint ) ; } else { ...
Returns if the current rectangle contains the defined location .
228,626
public final function containsSize ( $ widthOrSize , int $ height = null ) : bool { $ width = $ widthOrSize ; if ( $ width instanceof Size ) { $ height = $ width -> height ; $ width = $ width -> width ; } else if ( \ is_integer ( $ widthOrSize ) ) { $ width = $ widthOrSize ; } else if ( TypeTool :: IsInteger ( $ widthO...
Returns if the current rectangle contains the defined Size .
228,627
public function getClone ( ) : Rectangle { return new Rectangle ( new Point ( $ this -> point -> x , $ this -> point -> y ) , new Size ( $ this -> size -> width , $ this -> size -> height ) ) ; }
Gets a clone of the current instance .
228,628
public function toArray ( ) : array { return [ 'x' => $ this -> point -> x , 'y' => $ this -> point -> y , 'width' => $ this -> size -> width , 'height' => $ this -> size -> height ] ; }
Returns a array with all instance data . Used array keys are x y width and height .
228,629
public function generateProcessProxy ( $ arguments = array ( ) ) { if ( ! $ this -> isProxyLoaded ( ) ) { $ this -> loadProxyClass ( ) ; } $ reflect = new ReflectionClass ( $ this -> proxyClass ) ; return $ reflect -> newInstanceArgs ( $ arguments ) ; }
Instantiate and returns a step proxy .
228,630
public function writeProxyClassCache ( ) { $ parameters = array ( 'proxyNameSpace' => $ this -> getProxyNameSpace ( ) , 'proxyClassName' => $ this -> proxyClass , 'shortClassName' => $ this -> getShortClassName ( ) , 'originalClassName' => $ this -> class , ) ; $ proxyClassDefinition = $ this -> render ( $ this -> temp...
Writes the proxy class definition into a cache file .
228,631
public function loadProxyClass ( ) { if ( ! $ this -> cacheFileExists ( ) || $ this -> debug ) { $ this -> writeProxyClassCache ( ) ; } if ( ! $ this -> isProxyLoaded ( ) ) { require $ this -> proxyClassCacheFilename ; } return $ this ; }
Loads the proxy class for usage .
228,632
protected function render ( $ filepath , $ data = NULL ) { if ( ! file_exists ( $ filepath ) ) { throw new \ RuntimeException ( "View cannot render `$filepath` because the template does not exist" ) ; } $ data = $ this -> getData ( ) ; $ contentType = 'application/octet-stream' ; if ( isset ( $ data [ "CONTENT_TYPE" ] ...
Render - > Download file .
228,633
public function getRelativePath ( string $ fromDir , string $ to ) : string { if ( strpos ( $ to , 'data://' ) === 0 ) { return $ to ; } list ( $ fromStreamWrapper , $ fromDirPath ) = $ this -> splitStreamWrapperAndPath ( $ fromDir ) ; list ( $ toStreamWrapper , $ toPath ) = $ this -> splitStreamWrapperAndPath ( $ to )...
Gets the relative path from the first path to the second path .
228,634
public function resolveRelativePath ( string $ basePath , string $ relativePath ) : string { if ( strpos ( $ relativePath , 'data://' ) === 0 ) { return $ relativePath ; } list ( $ basePathStreamWrapper , $ basePath ) = $ this -> splitStreamWrapperAndPath ( $ basePath ) ; list ( $ relativeStreamWrapper , $ relativePath...
Combines the two paths and resolves .. and . relative traversals .
228,635
protected function isHTML ( ) { if ( function_exists ( 'headers_list' ) && $ headers = headers_list ( ) ) { foreach ( ( array ) $ headers as $ header ) { $ header = strtolower ( $ header ) ; if ( strpos ( $ header , 'content-type:' ) === 0 && ! strpos ( $ header , 'text/html' ) ) { return false ; } } } return true ; }
Whether the page is a plain old HTML .
228,636
public function minify ( ) { if ( $ this -> isHTML ( ) && class_exists ( 'Minify_HTML' ) ) { $ page = ob_get_contents ( ) ; ob_clean ( ) ; echo Minify_HTML :: minify ( $ page ) ; } }
Minifies the HTML page .
228,637
protected function pgsqlConnectionString ( ) { return $ this -> driver . ':host=' . $ this -> host . ';port=' . $ this -> port . ';dbname=' . $ this -> dbname . ';user=' . $ this -> user . ';password=' . $ this -> password ; }
pgsqlConnectionString Postgres connection string
228,638
protected function setProperties ( array $ properties = [ ] ) { foreach ( $ properties as $ name => $ value ) { if ( property_exists ( $ this , $ name ) ) { $ this -> $ name = $ value ; } else { trigger_error ( sprintf ( 'unknown property "%s" for "%s"' , $ name , get_class ( $ this ) ) , E_USER_WARNING ) ; } } }
Set properties trigger warning if unknown property found
228,639
public function config ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ key => $ value ) { $ this -> config ( $ key , $ value ) ; } return true ; } if ( isset ( $ value ) ) { $ this -> container [ 'settings' ] [ $ name ] = $ value ; } if ( ! isset ( $ this -> container [ 'settings' ] [ $...
Configure application settings
228,640
public function make ( $ className ) { $ reflection = new \ ReflectionClass ( $ className ) ; $ constructor = $ reflection -> getConstructor ( ) ; if ( is_null ( $ constructor ) ) { return new $ className ; } $ dependencies = [ ] ; $ parameters = $ reflection -> getConstructor ( ) -> getParameters ( ) ; foreach ( $ par...
Makes an instance of a class
228,641
private function runAction ( ) { $ url = $ this -> request -> url ( ) ; $ action = $ this -> router -> getAction ( $ url ) ; if ( $ action [ 'filter' ] ) { $ filter = $ this -> router -> performFilter ( $ action [ 'filter' ] ) ; } if ( ! isset ( $ action ) || ! is_string ( $ action [ 'class' ] ) || ! class_exists ( $ a...
Setups a database connection for models
228,642
private function returnValidationErrorResponse ( $ e ) { return $ this -> response -> error ( $ e -> getCode ( ) , $ e -> getMessage ( ) , [ 'error' => [ 'errors' => $ e -> getErrors ( ) ] ] ) ; }
Returns a validation error response
228,643
private function returnDatabaseErrorResponse ( $ e ) { $ info = $ this -> config ( 'debug.queries' ) ? [ 'error' => [ 'errors' => $ this -> db -> statement -> errorInfo ( ) , 'last_query' => $ this -> db -> lastQuery ( ) ] ] : [ ] ; return $ this -> response -> error ( 500 , 'Database error' , $ info ) ; }
Returns a database error response
228,644
private function returnGeneralErrorResponse ( $ e ) { $ backtrace = $ this -> config ( 'debug.backtrace' ) ? [ 'error' => [ 'backtrace' => $ e -> getTrace ( ) ] ] : [ ] ; return $ this -> response -> error ( $ e -> getCode ( ) , $ e -> getMessage ( ) , $ backtrace ) ; }
Returns a generic error response
228,645
public function updateCountry ( Country $ country , $ andFlush = true ) { $ this -> objectManager -> persist ( $ country ) ; if ( $ andFlush ) { $ this -> objectManager -> flush ( ) ; } }
Updates a Country .
228,646
public function refreshCountry ( Country $ country ) { $ refreshedCountry = $ this -> findCountryBy ( array ( 'id' => $ country -> getId ( ) ) ) ; if ( null === $ refreshedCountry ) { throw new UsernameNotFoundException ( sprintf ( 'User with ID "%d" could not be reloaded.' , $ country -> getId ( ) ) ) ; } return $ ref...
Refreshed a Country by Country Instance
228,647
public function finalizeConfig ( ) : void { if ( $ this -> locked ) { return ; } if ( null === $ this -> valueComparator ) { foreach ( $ this -> supportedValueTypes as $ type => $ supported ) { if ( $ supported && isset ( class_implements ( $ type ) [ RequiresComparatorValueHolder :: class ] ) ) { throw new InvalidConf...
Finalize the configuration and mark config as locked .
228,648
public static function to ( ? string $ path = '/' , ? int $ code = null ) { $ redirect = new Redirect ; $ redirect -> url = $ path ; if ( $ code !== null ) { $ redirect -> code = $ code ; return $ redirect -> send ( ) ; } return $ redirect ; }
Redirect to path
228,649
public static function back ( ? int $ code = null ) { if ( isset ( getallheaders ( ) [ 'Referer' ] ) ) { return Redirect :: to ( getallheaders ( ) [ 'Referer' ] , $ code ) ; } return new Redirect ( '/' ) ; }
Redirect back to the previous page
228,650
public function route ( string $ name , ? array $ parameters = [ ] , ? int $ code = null ) { $ this -> url = Route :: url ( $ name , $ parameters ) ; if ( $ code !== null ) { $ this -> code = $ code ; return $ this -> send ( ) ; } return $ this ; }
Redirect to route
228,651
public function with ( string $ name , $ value , ? int $ code = null ) { $ this -> with = array_merge ( [ $ name => $ value ] , $ this -> with ) ; if ( $ code != null ) { $ this -> code = $ code ; return $ this -> send ( ) ; } return $ this ; }
Attach variables with redirect
228,652
public function old ( array $ value , ? int $ code = null ) { $ this -> with = array_merge ( [ 'form.old' => $ value ] , $ this -> with ) ; if ( $ code != null ) { $ this -> code = $ code ; return $ this -> send ( ) ; } return $ this ; }
Attach old variables with redirect
228,653
public function return ( ? int $ code = null , ? string $ path = null ) { $ info = ( ( isset ( $ _SERVER [ 'PATH_INFO' ] ) ? $ _SERVER [ 'PATH_INFO' ] : '/' ) === '/' ? '' : $ _SERVER [ 'PATH_INFO' ] ) ; if ( $ info !== '' ) $ path = '?url=' . $ info ; if ( count ( $ _GET ) > 0 ) { $ path .= '&' . $ _SERVER [ 'QUERY_ST...
Allow redirect to return to current url
228,654
public function add ( $ comment ) { $ comments = $ this -> session -> get ( 'comments' , [ ] ) ; $ comments [ ] = $ comment ; $ this -> session -> set ( 'comments' , $ comments ) ; }
Add a new comment .
228,655
public function onKernelController ( FilterControllerEvent $ event ) { $ controller = $ event -> getController ( ) ; if ( ! is_array ( $ controller ) ) { return ; } $ fullpath = $ event -> getRequest ( ) -> get ( 'fullpath' ) ; if ( $ fullpath != '' && $ fullpath [ mb_strlen ( $ fullpath ) - 1 ] == '/' ) { $ fullpath =...
OnKernelControler event filter Try to find the page into database .
228,656
protected function setOptions ( array $ options ) { $ whitelist = array ( 'save_path' , 'name' , 'save_handler' , 'auto_start' , 'gc_probability' , 'gc_divisor' , 'gc_maxlifetime' , 'serialize_handler' , 'cookie_lifetime' , 'cookie_path' , 'cookie_domain' , 'cookie_secure' , 'cookie_httponly' , 'use_cookies' , 'use_onl...
Sets session options .
228,657
final public function importHTML ( $ html ) { $ tmp_doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ tmp_doc -> loadHTML ( $ html ) ; $ nodes = array ( ) ; foreach ( $ tmp_doc -> documentElement -> childNodes as $ node ) { array_push ( $ nodes , $ node ) ; $ this -> appendChild ( $ this -> ownerDocument -> importNode ( ...
Import HTML into a DOMElement
228,658
protected function getSet ( array $ queryParts ) { if ( isset ( $ queryParts [ 'set' ] ) && ! empty ( $ queryParts [ 'set' ] ) ) { $ updates = array ( ) ; foreach ( $ queryParts [ 'set' ] as $ k => $ v ) { $ updates [ ] = sprintf ( '%s = %s' , $ this -> quoteIdentifier ( $ k ) , $ this -> quote ( $ v ) ) ; } return 'SE...
Prepare the SET part of the MySQL query .
228,659
protected function getTable ( array $ queryParts ) { if ( isset ( $ queryParts [ 'table' ] ) ) { $ from = ( isset ( $ queryParts [ 'fields' ] ) && ! empty ( $ queryParts [ 'fields' ] ) ) || strtoupper ( $ queryParts [ 'type' ] ) === 'DELETE' ? 'FROM ' : '' ; if ( is_a ( $ queryParts [ 'table' ] , 'Database\Table' ) ) {...
Prepare the table name for use in the MySQL query .
228,660
protected function getJoins ( array $ queryParts ) { $ result = null ; if ( isset ( $ queryParts [ 'join' ] ) && ! empty ( $ queryParts [ 'join' ] ) ) { $ result = [ ] ; foreach ( $ queryParts [ 'join' ] as $ join ) { $ piece = trim ( $ join [ 0 ] . ' JOIN' ) . ' ' ; $ piece .= is_a ( $ join [ 1 ] , 'Database\Table' ) ...
Prepare the joins for use in the MySQL query .
228,661
private function formatWhere ( $ where , $ operator = 'AND' ) { if ( is_string ( $ where ) ) { return $ where ; } $ fullWhere = [ ] ; if ( is_array ( $ where ) ) { foreach ( $ where as $ key => $ value ) { $ fullWhere [ ] = sprintf ( '%s = %s' , $ this -> quoteIdentifier ( $ key ) , $ this -> quote ( $ value ) ) ; } } ...
Format the where clause of a MySQL query from a mixed range of types .
228,662
protected function getWhere ( array $ queryParts ) { if ( ! isset ( $ queryParts [ 'where' ] ) || empty ( $ queryParts [ 'where' ] ) ) { return null ; } $ where = array ( ) ; foreach ( $ queryParts [ 'where' ] as $ w ) { $ where [ ] = $ this -> formatWhere ( $ w ) ; } return 'WHERE ' . implode ( ' AND ' , $ where ) ; }
Prepare the where clause for use in the MySQL query .
228,663
protected function getGroup ( array $ queryParts ) { if ( isset ( $ queryParts [ 'group' ] ) ) { $ group = [ ] ; foreach ( $ queryParts [ 'group' ] as $ column ) { $ group [ ] = $ this -> quoteIdentifier ( $ column ) ; } return 'GROUP BY ' . implode ( ', ' , $ group ) ; } return null ; }
Prepare the group for use in the MySQL query .
228,664
protected function getOrder ( array $ queryParts ) { if ( isset ( $ queryParts [ 'order' ] ) ) { $ order = [ ] ; foreach ( $ queryParts [ 'order' ] as $ array ) { $ order [ ] = $ this -> quoteIdentifier ( $ array [ 0 ] ) . ( strtolower ( $ array [ 1 ] ) === 'asc' ? ' ASC' : ' DESC' ) ; } return 'ORDER BY ' . implode ( ...
Prepare the order for use in the MySQL query .
228,665
protected function getLimit ( array $ queryParts ) { if ( isset ( $ queryParts [ 'limit' ] ) && ! empty ( $ queryParts [ 'limit' ] ) ) { $ limit = [ ] ; foreach ( $ queryParts [ 'limit' ] as $ int ) { $ limit [ ] = ( int ) $ int ; } return 'LIMIT ' . implode ( ', ' , $ limit ) ; } return null ; }
Prepare the limit for use in the MySQL query .
228,666
public function buildQuery ( QueryAbstract $ query ) { $ queryParts = $ query -> getQueryParts ( ) ; return implode ( ' ' , array_filter ( [ $ queryParts [ 'type' ] , $ this -> getFields ( $ queryParts ) , $ this -> getTable ( $ queryParts ) , $ this -> getSet ( $ queryParts ) , $ this -> getValues ( $ queryParts ) , $...
Build a query string from a QueryAbstract
228,667
public function offsetUnset ( $ offset ) { unset ( $ this -> map [ $ offset ] ) ; $ this -> origin = $ this -> map -> keys ( ) ; return $ this ; }
ArrayAccess . Deletes the given key offset .
228,668
protected function castToArray ( & $ subject ) { if ( is_array ( $ subject ) === false ) { if ( Arr :: accessible ( $ subject ) === false ) { $ subject = new Collection ( $ subject ) ; } $ subject = $ subject instanceof Arrayable ? $ subject -> toArray ( ) : ( array ) $ subject ; } return $ this ; }
Because of the enumerable ways non - arrays can act like arrays we create a Collection which has useful normalizer functions and return that as an array .
228,669
protected function defineKeys ( & $ subject , array $ attributes , $ value = null ) { foreach ( $ attributes as $ attribute ) { $ subject [ $ attribute ] = $ value ; } return $ this ; }
Define the given array of attributes as keys in the given subject .
228,670
protected function pushAttributes ( & $ subject , array $ attributes , bool $ unique = true ) { foreach ( $ attributes as $ attribute ) { if ( $ unique === false || in_array ( $ attribute , $ subject ) === false ) { $ subject [ ] = $ attribute ; } } return $ this ; }
Push the given array of attributes to the given subject .
228,671
public static function passwordHash ( string $ text ) : ? string { return password_hash ( $ text , self :: PASSWORD_CRYPT_ALGO , [ 'cost' => self :: PASSWORD_CRYPT_COST ] ) ; }
Generate password hash using php password_hash with predefined algo
228,672
public static function passwordVerify ( string $ password , string $ hash ) : bool { return ( Str :: length ( $ hash ) > 0 && password_verify ( $ password , $ hash ) ) ; }
Verify password to hash equality
228,673
public static function randomString ( int $ length ) : string { try { $ rand = bin2hex ( random_bytes ( $ length ) ) ; $ rand = substr ( $ rand , 0 , $ length ) ; } catch ( \ Exception $ ce ) { $ rand = Str :: randomLatinNumeric ( $ length ) ; } return $ rand ; }
Generate random string with numbers from secure function random_bytes
228,674
public function runAction ( ) { $ request = $ this -> getRequest ( ) ; $ serviceParameters = array ( ) ; foreach ( $ this -> paramsToTest as $ params ) { foreach ( $ params as $ param ) { if ( $ result = $ request -> getParam ( $ param ) ) { $ serviceParameters [ $ params [ 0 ] ] = $ result ; continue ; } } } $ runner ...
Runs all tests and sets the exit code
228,675
public function transform ( $ entities ) { if ( is_null ( $ entities ) || count ( $ entities ) === 0 ) { return [ ] ; } $ data = [ ] ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; foreach ( $ entities as $ entity ) { $ text = is_null ( $ this -> textProperty ) ? ( string ) $ entity : $ accessor -> getVal...
Transform initial entities to array
228,676
private function setHeaders ( $ headers ) { $ headers = explode ( PHP_EOL , $ headers ) ; foreach ( $ headers as $ header ) { $ header = explode ( ': ' , $ header ) ; if ( ! is_array ( $ header ) && count ( $ header ) === 1 ) { continue ; } $ type = strtolower ( array_shift ( $ header ) ) ; $ value = implode ( ': ' , $...
Parse and store the headers
228,677
function Save ( ) { if ( ! $ this -> rights ) { $ this -> rights = new BackendContentRights ( ) ; } $ this -> rights -> SetCreateIn ( $ this -> Value ( 'CreateIn' ) ) ; $ this -> rights -> SetEdit ( $ this -> Value ( 'Edit' ) ) ; $ this -> rights -> SetMove ( $ this -> Value ( 'Move' ) ) ; $ this -> rights -> SetRemove...
Saves the content rights
228,678
public function getAncestorsNames ( ) { $ names = [ ] ; if ( $ this -> hasParent ( ) ) { $ names = $ this -> getParent ( ) -> getAncestorsNames ( ) ; } $ names [ ] = $ this -> getName ( ) ; return $ names ; }
Get all ancestors names . It includes the name of the object itself .
228,679
public function getDescendants ( ) { $ descendants = [ ] ; if ( $ this -> hasChildren ( ) ) { foreach ( $ this -> getChildren ( ) as $ child ) { $ childDescendants = $ child -> hasChildren ( ) ? $ child -> getDescendants ( ) : [ ] ; $ descendants = ArrayUtils :: merge ( $ descendants , ArrayUtils :: merge ( [ $ child ]...
Get all descendants .
228,680
public function getUsers ( ) { if ( $ this -> users === null ) { $ this -> setUsers ( $ this -> userRepository -> getAllByEnvironment ( $ this ) ) ; } return $ this -> users ; }
Get Users .
228,681
public function getCurrentRevision ( ) { if ( $ this -> currentRevision === null ) { $ this -> setCurrentRevision ( $ this -> revisionRepository -> getCurrentByEnvironment ( $ this ) ) ; } return $ this -> currentRevision ; }
Get CurrentRevision .
228,682
public function getLastReleasedRevision ( ) { if ( $ this -> lastReleasedRevision === null ) { $ this -> setLastReleasedRevision ( $ this -> revisionRepository -> getLastReleasedByEnvironment ( $ this ) ) ; } return $ this -> lastReleasedRevision ; }
Get LastReleasedRevision .
228,683
public function getReleasedRevisions ( ) { if ( $ this -> releasedRevisions === null ) { $ this -> setReleasedRevisions ( $ this -> revisionRepository -> getAllReleasedByEnvironment ( $ this ) ) ; } return $ this -> releasedRevisions ; }
Get ReleasedRevisions .
228,684
public function load ( Target $ target , array $ subjects , Service $ service ) : Acl { $ key = $ this -> buildKey ( $ target , $ subjects ) ; if ( ! isset ( $ this -> cache [ $ key ] ) ) { $ acl = $ this -> delegate -> load ( $ target , $ subjects , $ service ) ; $ this -> cache [ $ key ] = $ acl ; } return $ this -> ...
Loads the ACL for a Target .
228,685
public function loadAll ( array $ targets , array $ subjects , Service $ service ) : array { $ acls = [ ] ; if ( $ this -> delegate instanceof MultiStrategy ) { $ oids = array_merge ( $ targets ) ; foreach ( $ targets as $ i => $ target ) { if ( ! ( $ target instanceof Target ) ) { throw new \ InvalidArgumentException ...
Loads the ACLs for several Targets .
228,686
protected function buildKey ( Target $ target , array $ subjects ) : string { $ key = ( string ) $ target ; foreach ( $ subjects as $ subject ) { if ( ! ( $ subject instanceof Subject ) ) { throw new \ InvalidArgumentException ( "Only instances of Subject are permitted in the subjects argument" ) ; } $ key .= ";{$subje...
Generates the key to use for caching the ACL .
228,687
public static function getSelfURL ( ) { $ selfURLhost = self :: getSelfURLhost ( ) ; $ requestURI = '' ; if ( ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ requestURI = $ _SERVER [ 'REQUEST_URI' ] ; if ( $ requestURI [ 0 ] !== '/' ) { if ( preg_match ( '#^https?://[^/]*(/.*)#i' , $ requestURI , $ matches ) ) { $ reques...
Returns the URL of the current host + current view + query .
228,688
public static function castKey ( XMLSecurityKey $ key , $ algorithm , $ type = 'public' ) { assert ( 'is_string($algorithm)' ) ; assert ( '$type === "public" || $type === "private"' ) ; if ( $ key -> type === $ algorithm ) { return $ key ; } if ( ! OneLogin_Saml2_Utils :: isSupportedSigningAlgorithm ( $ algorithm ) ) {...
Converts a XMLSecurityKey to the correct algorithm .
228,689
protected function equality ( $ comparison , $ operand ) { return $ this -> expr -> addCondition ( new Operator \ Equality ( $ this , $ comparison , $ this -> expr -> value ( $ operand ) ) ) ; }
Add a comparison to the current expression .
228,690
public static function labels ( $ q ) { $ e = explode ( '.' , $ q ) ; $ r = '' ; for ( $ i = 0 , $ s = sizeof ( $ e ) ; $ i < $ s ; ++ $ i ) { $ r .= chr ( strlen ( $ e [ $ i ] ) ) . $ e [ $ i ] ; } if ( static :: binarySubstr ( $ r , - 1 ) !== "\x00" ) { $ r .= "\x00" ; } return $ r ; }
Build structure of labels .
228,691
public static function parseLabels ( & $ data , $ orig = null ) { $ str = '' ; while ( strlen ( $ data ) > 0 ) { $ l = ord ( $ data [ 0 ] ) ; if ( $ l >= 192 ) { $ pos = static :: bytes2int ( chr ( $ l - 192 ) . static :: binarySubstr ( $ data , 1 , 1 ) ) ; $ data = static :: binarySubstr ( $ data , 2 ) ; $ ref = stati...
Parse structure of labels .
228,692
public static function LV ( $ str , $ len = 1 , $ lrev = false ) { $ l = static :: i2b ( $ len , strlen ( $ str ) ) ; if ( $ lrev ) { $ l = strrev ( $ l ) ; } return $ l . $ str ; }
Build length - value binary snippet .
228,693
public static function getByte ( & $ p ) { $ r = static :: bytes2int ( $ p { 0 } ) ; $ p = static :: binarySubstr ( $ p , 1 ) ; return ( int ) $ r ; }
Parse byte and remove it .
228,694
public static function getString ( & $ str ) { $ p = strpos ( $ str , "\x00" ) ; if ( $ p === false ) { return '' ; } $ r = static :: binarySubstr ( $ str , 0 , $ p ) ; $ str = static :: binarySubstr ( $ str , $ p + 1 ) ; return $ r ; }
Parse null - terminated string .
228,695
public static function getLV ( & $ p , $ l = 1 , $ nul = false , $ lrev = false ) { $ s = static :: b2i ( static :: binarySubstr ( $ p , 0 , $ l ) , ! ! $ lrev ) ; $ p = static :: binarySubstr ( $ p , $ l ) ; if ( $ s == 0 ) { return '' ; } $ r = '' ; if ( strlen ( $ p ) < $ s ) { echo ( "getLV error: buf length (" . s...
Parse length - value structure .
228,696
public static function int2bytes ( $ len , $ int = 0 , $ l = false ) { $ hexstr = dechex ( $ int ) ; if ( $ len === null ) { if ( strlen ( $ hexstr ) % 2 ) { $ hexstr = "0" . $ hexstr ; } } else { $ hexstr = str_repeat ( '0' , $ len * 2 - strlen ( $ hexstr ) ) . $ hexstr ; } $ bytes = strlen ( $ hexstr ) / 2 ; $ bin = ...
Converts integer to binary string .
228,697
public static function bytes2int ( $ str , $ l = false ) { if ( $ l ) { $ str = strrev ( $ str ) ; } $ dec = 0 ; $ len = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ dec += ord ( static :: binarySubstr ( $ str , $ i , 1 ) ) * pow ( 0x100 , $ len - $ i - 1 ) ; } return $ dec ; }
Convert bytes into integer .
228,698
public static function bitmap2bytes ( $ bitmap , $ checkLen = 0 ) { $ r = '' ; $ bitmap = str_pad ( $ bitmap , ceil ( strlen ( $ bitmap ) / 8 ) * 8 , '0' , STR_PAD_LEFT ) ; for ( $ i = 0 , $ n = strlen ( $ bitmap ) / 8 ; $ i < $ n ; ++ $ i ) { $ r .= chr ( ( int ) bindec ( static :: binarySubstr ( $ bitmap , $ i * 8 , ...
Convert bitmap into bytes .
228,699
protected static function binarySubstr ( $ s , $ p , $ len = null ) { if ( $ len === null ) { $ ret = substr ( $ s , $ p ) ; } else { $ ret = substr ( $ s , $ p , $ len ) ; } if ( $ ret === false ) { $ ret = '' ; } return $ ret ; }
Binary Substring .