idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
13,400
public static function unXss ( $ input ) { if ( self :: isTraversable ( $ input ) ) { foreach ( $ input as & $ i ) { $ i = self :: unXss ( $ i ) ; } } elseif ( is_scalar ( $ input ) ) { $ input = htmlspecialchars ( $ input , ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE ) ; } return $ input ; }
Protects the input from cross - site scripting attacks
13,401
protected function init ( $ config ) { parent :: init ( $ config ) ; if ( ! $ this -> dataUrl ) { $ this -> dataUrl = WebApp :: get ( ) -> request ( ) -> getCurrentURL ( ) ; } if ( $ this -> handleRequest ) { $ this -> _handle ( ) ; die ( ) ; } return true ; }
It will take care of upload and delete requests ;
13,402
public function display ( ) { $ source = str_replace ( [ '{VENDOR}' , '{APP_ROOT}' ] , [ LIBS_FOLDER , APP_ROOT ] , $ this -> jsSource ) ; $ url = AssetsPublisher :: get ( ) -> publishFolder ( $ source ) ; $ events = $ this -> getJSEvents ( ) ; $ r = Form :: get ( ) -> input ( $ this -> name . '[]' , 'file' , null , [ 'id' => $ this -> id , 'data-url' => $ this -> dataUrl , 'multiple' => 'multiple' , ] ) . Html :: get ( ) -> scriptFile ( $ url . "js/vendor/jquery.ui.widget.js" ) . Html :: get ( ) -> scriptFile ( $ url . "js/jquery.iframe-transport.js" ) . Html :: get ( ) -> scriptFile ( $ url . "js/jquery.fileupload.js" ) . Html :: get ( ) -> script ( "\$(function () { \$('#{$this->id}').fileupload({ dataType: 'json' " . ( isset ( $ this -> jsEventsHandlers [ 'fileuploaddone' ] ) ? '' : ", done: function (e, data) { $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo($(\"#{$this->resultsId}\")); }); }" ) . " })$events;});" ) ; if ( $ this -> generateResultsDiv ) { $ r .= Html :: get ( ) -> tag ( "div" , "" , [ "id" => $ this -> resultsId ] ) ; } return $ r ; }
Returns the HTML code for the element .
13,403
public function getDocComment ( $ withCommentMark = false ) { $ docComment = $ this -> _reflectionClass -> getDocComment ( ) ; if ( $ withCommentMark === false ) { $ docComment = PhpDocCommentObject :: stripCommentMarks ( $ docComment ) ; } return $ docComment ; }
Get DocComment of class
13,404
public function setLength ( $ length ) { if ( ( $ length !== null ) && ( ! is_int ( $ length ) || ( $ length <= 0 ) ) ) { throw SchemaException :: invalidColumnLength ( $ this -> getName ( ) ) ; } $ this -> length = $ length ; }
Sets the column length .
13,405
public function setPrecision ( $ precision ) { if ( ( $ precision !== null ) && ( ! is_int ( $ precision ) || ( $ precision <= 0 ) ) ) { throw SchemaException :: invalidColumnPrecision ( $ this -> getName ( ) ) ; } $ this -> precision = $ precision ; }
Sets the column precision .
13,406
public function setScale ( $ scale ) { if ( ( $ scale !== null ) && ( ! is_int ( $ scale ) || ( $ scale < 0 ) ) ) { throw SchemaException :: invalidColumnScale ( $ this -> getName ( ) ) ; } $ this -> scale = $ scale ; }
Sets the column scale .
13,407
public function setUnsigned ( $ unsigned ) { if ( ( $ unsigned !== null ) && ! is_bool ( $ unsigned ) ) { throw SchemaException :: invalidColumnUnsignedFlag ( $ this -> getName ( ) ) ; } $ this -> unsigned = $ unsigned ; }
Sets the column unsigned flag .
13,408
public function setFixed ( $ fixed ) { if ( ( $ fixed !== null ) && ! is_bool ( $ fixed ) ) { throw SchemaException :: invalidColumnFixedFlag ( $ this -> getName ( ) ) ; } $ this -> fixed = $ fixed ; }
Sets the column fixed flag .
13,409
public function setNotNull ( $ notNull ) { if ( ( $ notNull !== null ) && ! is_bool ( $ notNull ) ) { throw SchemaException :: invalidColumnNotNullFlag ( $ this -> getName ( ) ) ; } $ this -> notNull = $ notNull ; }
Sets the column not null flag .
13,410
public function setAutoIncrement ( $ autoIncrement ) { if ( ( $ autoIncrement !== null ) && ! is_bool ( $ autoIncrement ) ) { throw SchemaException :: invalidColumnAutoIncrementFlag ( $ this -> getName ( ) ) ; } $ this -> autoIncrement = $ autoIncrement ; }
Sets the column auto increment flag .
13,411
public function setComment ( $ comment ) { if ( ( $ comment !== null ) && ! is_string ( $ comment ) ) { throw SchemaException :: invalidColumnComment ( $ this -> getName ( ) ) ; } $ this -> comment = $ comment ; }
Sets the column comment .
13,412
public function setProperties ( array $ properties ) { foreach ( $ properties as $ property => $ value ) { $ method = sprintf ( 'set%s' , str_replace ( '_' , '' , $ property ) ) ; if ( ! method_exists ( $ this , $ method ) ) { throw SchemaException :: invalidColumnProperty ( $ this -> getName ( ) , $ property ) ; } $ this -> $ method ( $ value ) ; } }
Sets the column options .
13,413
public function toArray ( ) { return array ( 'name' => $ this -> getName ( ) , 'type' => $ this -> getType ( ) -> getName ( ) , 'length' => $ this -> getLength ( ) , 'precision' => $ this -> getPrecision ( ) , 'scale' => $ this -> getScale ( ) , 'unsigned' => $ this -> isUnsigned ( ) , 'fixed' => $ this -> isFixed ( ) , 'not_null' => $ this -> isNotNull ( ) , 'default' => $ this -> getDefault ( ) , 'auto_increment' => $ this -> isAutoIncrement ( ) , 'comment' => $ this -> getComment ( ) , ) ; }
Converts a column to an array .
13,414
public function add ( $ key , $ value ) { $ this -> collection [ $ key ] = $ value ; $ this -> indices [ $ this -> length ] = $ key ; $ this -> length ++ ; return $ this ; }
Add data to the collection .
13,415
public final function getPhpCode ( ) : string { $ str = $ this -> stringValue ; switch ( $ this -> typeName ) { case Type :: PHP_BOOLEAN : case 'boolean' : return ( $ this -> value ? 'true' : 'false' ) ; case Type :: PHP_DOUBLE : case Type :: PHP_FLOAT : case Type :: PHP_INTEGER : case 'integer' : return $ str ; case Type :: PHP_STRING : if ( \ preg_match ( "~[\r\n\t]+~" , $ str ) ) { $ str = \ str_replace ( array ( '\\' , "\r" , "\n" , "\t" , "\0" , '"' , '$' ) , array ( '\\\\' , '\\r' , '\\n' , '\\t' , '\\0' , '\\"' , '\\$' ) , $ str ) ; return '"' . $ str . '"' ; } return "'" . \ str_replace ( array ( '\\' , "'" ) , array ( '\\\\' , "\\'" ) , $ str ) . "'" ; case Type :: PHP_RESOURCE : case Type :: PHP_NULL : case Type :: PHP_UNKNOWN : return 'null' ; default : $ str = \ serialize ( $ this -> value ) ; if ( \ preg_match ( "~[\r\n\t]+~" , $ str ) ) { $ str = \ str_replace ( array ( '\\' , "\r" , "\n" , "\t" , "\0" , '"' , '$' ) , array ( '\\\\' , '\\r' , '\\n' , '\\t' , '\\0' , '\\"' , '\\$' ) , $ str ) ; } else { $ str = \ str_replace ( array ( '\\' , '"' , '$' ) , array ( '\\\\' , '\\"' , '\\$' ) , $ str ) ; } return '\unserialize("' . $ str . '")' ; } }
Returns the PHP code defining the current base value .
13,416
public function registerConnection ( $ name , array $ configuration ) { $ this -> configurations -> set ( $ name , new OrientDbMetadata ( $ configuration [ 'host' ] , $ configuration [ 'port' ] , $ configuration [ 'timeout' ] , $ configuration [ 'user' ] , $ configuration [ 'password' ] , $ configuration [ 'database' ] , $ configuration [ 'data_type' ] , $ configuration [ 'storage_type' ] ) ) ; }
Register a new OrientDB connection under given name
13,417
public function getConfiguration ( $ connectionName = 'default' ) { if ( ! $ this -> configurations -> containsKey ( $ connectionName ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Any registered configuration under given key.' ) ) ; } return $ this -> configurations -> get ( $ connectionName ) ; }
Return registered configuration under given connectionName
13,418
public function getConnection ( $ connectionName = 'default' ) { if ( $ this -> connections -> containsKey ( $ connectionName ) ) { return $ this -> connections -> get ( $ connectionName ) ; } $ configuration = $ this -> getConfiguration ( $ connectionName ) ; $ this -> connections -> set ( $ connectionName , $ database = ( new \ OrientDB ( $ configuration -> getHost ( ) , $ configuration -> getPort ( ) , $ configuration -> getTimeout ( ) ) ) ) ; $ database -> connect ( $ configuration -> getUser ( ) , $ configuration -> getPassword ( ) ) ; return $ database ; }
Return registered connection under given connectionName
13,419
public function createDatabase ( $ connectionName ) { $ configuration = $ this -> getConfiguration ( $ connectionName ) ; $ database = $ this -> getConnection ( $ connectionName ) ; $ database -> DBCreate ( $ configuration -> getDatabase ( ) , $ configuration -> getDataType ( ) , $ configuration -> getStorageType ( ) ) ; return $ this -> getDatabase ( $ connectionName ) ; }
Tries to create a database for given connection name
13,420
public function dropDatabase ( $ connectionName ) { $ configuration = $ this -> getConfiguration ( $ connectionName ) ; $ database = $ this -> getConnection ( $ connectionName ) ; $ database -> DBDelete ( $ configuration -> getDatabase ( ) ) ; }
Tries to drop a database for given connection name
13,421
public function getDatabase ( $ connectionName = 'default' ) { if ( $ this -> databases -> containsKey ( $ connectionName ) ) { return $ this -> databases -> get ( $ connectionName ) ; } $ configuration = $ this -> getConfiguration ( $ connectionName ) ; $ database = $ this -> getConnection ( $ connectionName ) ; $ database -> DBOpen ( $ configuration -> getDatabase ( ) , $ configuration -> getUser ( ) , $ configuration -> getPassword ( ) ) ; $ this -> databases -> set ( $ connectionName , $ database ) ; return $ this -> databases -> get ( $ connectionName ) ; }
Return registered database under given name
13,422
public function synchronize ( $ connectionName ) { $ configuration = $ this -> getConfiguration ( $ connectionName ) ; $ database = $ this -> getDatabase ( $ connectionName ) ; foreach ( $ configuration -> getVertexes ( ) as $ vertex ) { try { $ database -> query ( sprintf ( 'CREATE CLASS %s EXTENDS V' , $ vertex -> getName ( ) ) ) ; $ database -> query ( sprintf ( 'DISPLAY RECORD 0' , $ vertex -> getName ( ) ) ) ; dump ( $ res ) ; die ; } catch ( \ Exception $ e ) { if ( preg_match ( sprintf ( '/Class %s already exists in current database$/' , $ vertex -> getName ( ) ) , $ e -> getMessage ( ) ) ) { continue ; } throw $ e ; } } }
Synchronize vertexes and edges with related OrientDb database
13,423
public function generateSequence ( TerminalState $ state , $ reset ) { $ sequence = "" ; $ styles = [ ] ; if ( $ state -> isBold ( ) ) { $ styles [ ] = self :: BOLD ; } if ( $ state -> isUnderscore ( ) ) { $ styles [ ] = self :: UNDERSCORE ; } if ( $ state -> getTextColor ( ) -> isValid ( ) ) { $ styles [ ] = $ state -> getTextColor ( ) -> generateColorCoding ( $ this -> mode ) ; } if ( $ state -> getFillColor ( ) -> isValid ( ) ) { $ styles [ ] = $ state -> getFillColor ( ) -> generateColorCoding ( $ this -> mode , true ) ; } if ( count ( $ styles ) ) { $ sequence = self :: CSI ; if ( $ reset ) { $ sequence .= self :: CLEAR . ";" ; } for ( $ i = 0 ; $ i < count ( $ styles ) ; ++ $ i ) { $ sequence .= $ styles [ $ i ] ; if ( $ i < ( count ( $ styles ) - 1 ) ) { $ sequence .= ";" ; } } $ sequence .= self :: CSE ; } else { if ( $ reset ) { $ sequence .= self :: generateClearSequence ( ) ; } } return $ sequence ; }
Generate the escape sequencing for a particular state
13,424
public function generate ( TerminalStateInterface $ currentState , TerminalState $ desiredState ) { $ changes = $ currentState -> findChanges ( $ desiredState ) ; if ( $ changes ) { if ( $ changes -> isClear ( ) ) { return "" ; } else { return $ this -> generateSequence ( $ changes , false ) ; } } else { return $ this -> generateSequence ( $ desiredState , true ) ; } }
Generate an escape sequence based on the current state and the new desired state
13,425
private function createMapping ( ) { $ columns = $ this -> pdoStatement -> columnCount ( ) ; if ( $ columns > 0 ) { $ this -> mapping = [ ] ; for ( $ i = 0 ; $ i < $ columns ; $ i ++ ) { $ meta = $ this -> pdoStatement -> getColumnMeta ( $ i ) ; $ this -> mapping [ $ i ] = [ $ meta [ 'table' ] , $ meta [ 'name' ] ] ; } } }
Create the mapping to use for mapping the column names to a result array .
13,426
public function all ( ) { $ this -> reset ( ) ; $ result = [ ] ; while ( $ row = $ this -> get ( ) ) { $ result [ ] = $ row ; } return $ result ; }
Return an array with all the data from the query .
13,427
protected function match ( $ method , $ uri ) { $ result = null ; foreach ( ( array ) $ this -> router -> routes ( ) as $ route ) { $ matched = preg_match ( $ route -> regex ( ) , $ uri , $ matches ) ; if ( $ matched && $ route -> method ( ) === $ method ) { return array ( $ matches , $ route ) ; } } return $ result ; }
Matches the route from the parsed URI .
13,428
protected function requireSubmitValue ( ) { if ( $ this -> system -> input ( ) -> post ( 'submit' ) ) { echo 'LOOK: ' . $ this -> system -> input ( ) -> post ( 'submit' ) . PHP_EOL ; return ; } $ this -> setNotReady ( "No submit value present." ) ; }
Require Submit Value
13,429
protected function resolveRedirectRoute ( ) { if ( empty ( $ this -> redirectRoute ) ) return ; $ route = $ this -> system -> router ( ) -> getRouteByName ( $ this -> redirectRoute ) ; if ( empty ( $ route ) ) { $ this -> setNotReady ( "Unable to find route " . $ this -> redirectRoute ) ; return ; } $ this -> redirectURL = $ route -> getPath ( $ this -> redirectParameters ) ; }
Resolve redirect route
13,430
public static function prettyPrintMicroTimeInterval ( $ startTime , $ endTime ) { $ seconds = abs ( $ endTime - $ startTime ) ; return sprintf ( '%02d:%02d:%02d' , ( $ seconds / 3600 ) , ( $ seconds / 60 % 60 ) , $ seconds % 60 ) ; }
Pretty prints an interval specfied by two timestamps
13,431
public function all ( ) { $ ret = [ ] ; foreach ( $ this -> instances as $ instances ) { $ ret = array_merge ( $ ret , $ instances ) ; } return $ ret ; }
Get all instances
13,432
public function getAttribute ( $ name , $ default = NULL ) { return isset ( $ this -> attributes [ $ name ] ) ? $ this -> attributes [ $ name ] : $ default ; }
Returns an attribute by its name .
13,433
public function validate ( $ data , array $ rules = [ ] ) { $ this -> normalizeData ( $ data ) ; $ this -> setRules ( $ rules ) ; foreach ( $ this -> rules as $ attribute => $ rules ) { foreach ( $ rules as $ rule ) { $ this -> validateAttribute ( $ rule , $ attribute ) ; if ( $ this -> shouldStopValidating ( $ attribute ) ) break ; } } return $ this -> errors ; }
Run the validator s rules against its data .
13,434
protected function addError ( $ attribute , $ rule , array $ parameters ) { $ message = $ this -> getMessage ( $ attribute , $ rule , $ parameters ) ; $ this -> errors [ $ attribute ] [ 'errors' ] [ ] = $ message ; if ( ! isset ( $ this -> errors [ $ attribute ] [ 'value' ] ) ) { $ this -> errors [ $ attribute ] [ 'value' ] = $ this -> getValue ( $ attribute ) ; } }
Add an error message to the validator s collection of errors .
13,435
protected function normalizeData ( $ data ) { if ( is_object ( $ data ) ) { $ this -> data = get_object_vars ( $ data ) ; } else { $ this -> data = $ data ; } return $ this ; }
Normalize the provided data to an array .
13,436
protected function translator ( $ key , $ rule , $ attribute , array $ parameters ) { $ strings = [ ] ; $ message = isset ( $ strings [ $ key ] ) ? $ strings [ $ key ] : false ; if ( ! $ message ) return ; $ message = str_replace ( ':attribute' , $ attribute , $ message ) ; if ( method_exists ( $ this , $ replacer = "replace{$rule}" ) ) { $ message = $ this -> $ replacer ( $ message , $ parameters ) ; } return $ message ; }
Returns a translated message for the attribute
13,437
protected function validateAccepted ( $ value ) { $ acceptable = [ 'yes' , 'on' , '1' , 1 , true , 'true' ] ; return $ this -> validateRequired ( $ value ) && in_array ( $ value , $ acceptable , true ) ; }
Validate that an attribute was accepted .
13,438
protected function validateMin ( $ value , $ attribute , array $ parameters ) { $ this -> requireParameterCount ( 1 , $ parameters , 'min' ) ; return $ this -> getSize ( $ attribute , $ value ) >= $ parameters [ 0 ] ; }
Validate the size of an attribute is greater than a minimum value .
13,439
public static function resolve ( $ name ) { $ logger = $ GLOBALS [ 'logger' ] ; $ app = $ GLOBALS [ 'app' ] ; $ staticPath = 'public' ; if ( $ app -> getConfiguration ( ) -> isLocal ( ) ) { $ staticPath = 'views' ; } $ session = $ app -> getSessionManager ( ) -> getActiveSession ( ) ; $ category = $ session -> getAttribute ( 'category' ) ; $ basePath = '/' . $ staticPath . '/resources/' . $ category ; $ commonPath = '/' . $ staticPath . '/resources/common' ; $ searchFolder = '.' ; $ isUrl = false ; if ( preg_match ( '/.*\.js$/' , $ name ) ) { $ searchFolder = 'scripts' ; } else if ( preg_match ( '/.*\.css$/' , $ name ) ) { $ searchFolder = 'styles' ; } else if ( preg_match ( '/.*\.(?:jpg|jpeg|gif|png)$/' , $ name ) ) { $ searchFolder = 'images' ; } else { $ isUrl = true ; $ name = DIRECTORY_SEPARATOR . $ app -> getConfiguration ( ) -> getApplicationContext ( ) . DIRECTORY_SEPARATOR . $ name ; } if ( $ isUrl ) { return $ name ; } if ( file_exists ( getcwd ( ) . $ basePath . '/' . $ searchFolder . '/' . $ name ) ) { return '/' . $ app -> getConfiguration ( ) -> getApplicationContext ( ) . $ basePath . '/' . $ searchFolder . '/' . $ name ; } else if ( file_exists ( getcwd ( ) . $ commonPath . '/' . $ searchFolder . '/' . $ name ) ) { return '/' . $ app -> getConfiguration ( ) -> getApplicationContext ( ) . $ commonPath . '/' . $ searchFolder . '/' . $ name ; } return $ name ; }
Resolve Script Path based on name .
13,440
public function getDefaults ( ) { return array ( 'android' => false , 'browser' => self :: BROWSER , 'cookies' => ( count ( $ _COOKIE ) > 0 ) ? true : false , 'height' => self :: HEIGHT , 'hidpi' => ( array_key_exists ( 'HTTP_DPR' , $ _SERVER ) ) ? $ _SERVER [ 'HTTP_DPR' ] > 1 : false , 'ios' => false , 'low_speed' => false , 'low_battery' => false , 'metered' => $ this -> getMeteredDefault ( ) , 'touch' => self :: TOUCH , 'user-agent' => $ this -> getUserAgentDefault ( ) , 'viewport' => $ this -> getViewportDefault ( ) , 'width' => self :: WIDTH ) ; }
These defaults come from an number of places including client hints . The only values based on a UA string are the Android & iOS values .
13,441
private function getMeteredDefault ( ) { foreach ( self :: METERED_HEADERS as $ header ) { if ( array_key_exists ( $ header , $ _SERVER ) ) { return true ; } } return false ; }
Uses potential mobile headers & Google s new save - data header to determine if we have a metered connection .
13,442
public function policy ( Policy $ policy ) { $ this -> loadedPolicies [ ] = $ policy ; foreach ( $ policy -> getNodes ( ) as $ namespace => $ callable ) $ this -> getPermission ( $ namespace ) -> addPolicyMethod ( $ callable ) ; }
Adds a new policy checker .
13,443
protected function checkRaw ( $ namespace , PermissibleEntity $ entity = null ) { if ( $ namespace == null || strlen ( $ namespace ) == 0 || $ namespace == "everybody" || $ namespace == "-1" ) $ namespace = Permission :: EVERYBODY ; if ( $ namespace == "op" || $ namespace == "0" ) $ namespace = Permission :: OP ; if ( $ namespace == "admin" ) $ namespace = Permission :: ADMIN ; if ( $ namespace == "banned" ) $ namespace = Permission :: BANNED ; if ( $ namespace == "whitelisted" ) $ namespace = Permission :: WHITELISTED ; $ namespace = static :: getAlias ( $ namespace ) ; if ( ! preg_match ( "/[a-z0-9_.]*/" , $ namespace ) ) throw new PermissionException ( "The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'." ) ; $ permission_defaults = PermissionDefaults :: find ( $ namespace ) ; if ( $ entity === null ) { if ( ! Acct :: check ( ) ) { $ result = $ this -> checkWalker ( $ namespace , [ ] ) ; if ( $ result == PermissionValues :: UNSET ) $ result = $ permission_defaults -> value_default ; return $ result ; } $ entity = Acct :: acct ( ) ; } $ group_state = PermissionValues :: UNSET ; foreach ( $ entity -> groups ( ) as $ group ) { $ group_state = $ this -> checkRaw ( $ namespace , $ group ) ; if ( $ group_state == PermissionValues :: ALWAYS || $ group_state == PermissionValues :: NEVER ) break ; } $ user_state = $ this -> checkWalker ( $ namespace , $ entity -> permissions ( ) ) ; if ( $ group_state == PermissionValues :: ALWAYS || $ group_state == PermissionValues :: NEVER ) { if ( $ user_state == PermissionValues :: ALWAYS ) return true ; else if ( $ user_state == PermissionValues :: NEVER ) return false ; else return $ group_state ; } else if ( $ group_state == PermissionValues :: UNSET && $ user_state == PermissionValues :: UNSET ) return $ permission_defaults -> value_default ; else if ( $ user_state == PermissionValues :: UNSET ) return $ group_state ; else return $ user_state ; }
Checks a raw singular namespace and returns the unhindered result
13,444
public function check ( $ namespaces , PermissibleModel $ model = null , PermissibleEntity $ entity = null ) { $ instance = $ this ? : self :: i ( ) ; if ( ! is_array ( $ namespaces ) ) $ namespaces = [ $ namespaces ] ; foreach ( $ namespaces as & $ ns ) { if ( ! is_string ( $ ns ) ) throw new PermissionException ( "The permission namespace must be a string." ) ; $ ns = static :: getAlias ( $ ns ) ; if ( ! preg_match ( "/[a-z0-9_.]*/" , $ ns ) ) throw new PermissionException ( "The permission namespace [$ns] can only contain the characters 'a-z0-9_.'." ) ; } if ( $ model != null ) { if ( $ model instanceof PermissibleModel ) { $ namespaces_new = $ namespaces ; foreach ( $ model -> getIdentifiers ( ) as $ key => $ id ) $ namespaces_new = str_replace ( "{" . $ key . "}" , $ id , $ namespaces_new ) ; return $ instance -> check ( $ namespaces_new , null , $ entity ) ; } else throw new PermissionException ( "The 'model' must implement PermissibleModel." ) ; } $ current_state = PermissionValues :: UNSET ; array_walk ( $ namespaces , function ( $ ns ) use ( & $ instance , & $ entity , & $ current_state ) { $ current_state = $ instance -> checkRaw ( $ ns , $ entity ) ; Log :: debug ( "Checking permission [" . $ ns . "] on entity [" . ( $ entity ? get_class ( $ entity ) : "null" ) . "] with result [" . $ current_state . "]" ) ; if ( $ current_state == PermissionValues :: ALWAYS ) return true ; if ( $ current_state == PermissionValues :: NEVER ) return false ; if ( $ current_state == PermissionValues :: UNSET || ! PermissionValues :: valid ( $ current_state ) ) throw new PermissionException ( "Permission Exception!" ) ; } ) ; return $ current_state == PermissionValues :: YES ; }
Checks a permission for assignment and policy checks
13,445
protected function setCssFileCDN ( $ cssFileName ) { $ patternFound = null ; if ( strpos ( pathinfo ( $ cssFileName ) [ 'basename' ] , 'font-awesome-' ) !== false ) { $ patternFound = $ this -> setCssFileCDNforFontAwesome ( $ cssFileName ) ; } if ( is_null ( $ patternFound ) ) { $ patternFound = [ false , $ this -> sanitizeString ( $ cssFileName ) ] ; } return $ patternFound ; }
Manages all known CSS that can be handled through CDNs
13,446
private function setJavascriptFileCDNforHighChartsMain ( $ jsFileName , $ libName ) { $ jsFN = $ this -> sanitizeString ( $ jsFileName ) ; $ jsVersionlessFN = str_replace ( [ $ libName . '-' , '.js' ] , '' , pathinfo ( $ jsFileName ) [ 'basename' ] ) . ( $ libName === 'exporting' ? '/modules' : '' ) ; if ( strpos ( $ jsFileName , $ libName ) !== false ) { return [ true , $ this -> sCloundFlareUrl . 'highcharts/' . $ jsVersionlessFN . '/' . $ libName . '.js' , '<script>!window.Highcharts && document.write(\'<script src="' . $ jsFN . '">\x3C/script>\')</script>' , ] ; } return null ; }
Returns an array with CDN call of a known Javascript library and fall - back line that points to local cache of it specific for HighCharts
13,447
private function setJavascriptFileCDNjQuery ( $ jsFileName ) { $ jQueryPosition = strpos ( $ jsFileName , 'jquery-' ) ; $ jQueryMajorVersion = substr ( $ jsFileName , 7 , 1 ) ; if ( ( $ jQueryPosition !== false ) && is_numeric ( $ jQueryMajorVersion ) && ( substr ( $ jsFileName , - 7 ) == '.min.js' ) ) { return [ true , $ this -> sCloundFlareUrl . 'jquery/' . $ this -> getCmpltVers ( $ jsFileName , 'jquery-' ) . '/jquery.min.js' , '<script>window.jQuery || document.write(\'<script src="' . $ this -> sanitizeString ( $ jsFileName ) . '">\x3C/script>\')</script>' , ] ; } return null ; }
Returns an array with CDN call of a known Javascript library and fall - back line that points to local cache of it specific for jQuery
13,448
private function setJavascriptFileCDNjQueryLibs ( $ jsFileName ) { $ sFN = $ this -> sanitizeString ( $ jsFileName ) ; $ eArray = $ this -> knownCloudFlareJavascript ( $ sFN ) ; if ( ! is_null ( $ eArray [ 'version' ] ) ) { return [ true , $ this -> sCloundFlareUrl . $ eArray [ 'version' ] . $ eArray [ 'justFile' ] , '<script>' . $ eArray [ 'eVerify' ] . ' || document.write(\'<script src="' . $ sFN . '">\x3C/script>\')</script>' , ] ; } return null ; }
Returns an array with CDN call of a known Javascript library and fall - back line that points to local cache of it specific for jQuery Libraries
13,449
public function profileData ( ) { $ user = Auth :: user ( ) ; $ profile = UserProfile :: whereUserId ( $ user -> id ) -> first ( ) ; $ data = Input :: all ( ) ; $ rules = [ 'nombre' => 'required' , 'apellidos' => 'required' ] ; $ validator = Validator :: make ( $ data , $ rules ) ; if ( $ validator -> passes ( ) ) { $ profile -> fill ( $ data ) ; $ profile -> save ( ) ; return redirect ( ) -> route ( 'admin.user.profile' ) ; } else { return Redirect :: back ( ) -> withInput ( ) -> withErrors ( $ validator -> messages ( ) ) ; } }
Funcion para cambiar datos de Perfil de usuario logeado
13,450
public function contains ( $ type ) { foreach ( $ this -> tokens as $ token ) { if ( $ token -> is ( $ type ) ) { return true ; } } return false ; }
Check if the sequence contains at least one token of the given type .
13,451
public function containsOneOf ( array $ types ) { foreach ( $ this -> tokens as $ token ) { if ( $ token -> isOneOf ( $ types ) ) { return true ; } } return false ; }
Check if the sequence contains at least one token of any of the given token types .
13,452
public function endsWith ( $ type ) { if ( empty ( $ this -> tokens ) ) { return false ; } return $ this -> tokens [ count ( $ this -> tokens ) - 1 ] -> is ( $ type ) ; }
Check if the sequence ends with a token of the given token type .
13,453
public function setStatus ( $ status ) { $ status = ( int ) $ status ; if ( $ status < 100 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HTTP status code: %u' , $ status ) ) ; } if ( $ status >= 600 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HTTP status code: %u' , $ status ) ) ; } $ this -> status = $ status ; return $ this ; }
Set the HTTP status of this response .
13,454
public function removeCookie ( $ name ) { $ cookie = new SetCookieHeader ( $ name , '' ) ; $ cookie -> setExpires ( 1337 ) ; $ this -> addHeader ( $ cookie ) ; return $ this ; }
Remove a cookie by eliminating a Set - Cookie header for this cookie replacing it with a header that will cause the client to remove the cookie .
13,455
public function get ( callable $ codeBlock = null ) { if ( ! $ this -> result ) { $ this -> result = $ this -> run ( new Success ) ; } if ( $ this -> result instanceof Success ) { return is_callable ( $ codeBlock ) ? $ codeBlock ( $ this -> result ) : $ this -> result ; } return $ this -> result ; }
Returns the result of the code - block execution attempt .
13,456
public function bind ( callable $ codeBlock ) { return static :: unit ( function ( $ result ) use ( $ codeBlock ) { $ result = $ this -> run ( $ result ) ; if ( $ result instanceof Success ) { return $ codeBlock ( $ result ) ; } else { return $ result ; } } ) ; }
Returns a new Attempt monad that is bound to the given code - block .
13,457
protected function run ( MonadInterface $ prevResult , callable $ next = null ) { try { $ result = call_user_func ( $ this -> codeBlock , $ prevResult ) ; return ( $ result instanceof MonadInterface ) ? $ result : Success :: unit ( $ result ) ; } catch ( Exception $ error ) { return Error :: unit ( $ error ) ; } }
Runs the monad s code - block .
13,458
public function validateForm ( ) { if ( $ this -> validate ( ) ) { $ this -> encryptionKey = $ this -> getEncryptionKey ( ) ; $ this -> encryptedPassword = $ this -> getEncryptedPassword ( ) ; return true ; } return false ; }
Validates the model and provides the encrypted data stream for hashing
13,459
public function save ( ) { if ( ! $ this -> validateForm ( ) ) return false ; try { Yii :: app ( ) -> session [ 'encryptionKey' ] = $ this -> encryptionKey ; Yii :: app ( ) -> session [ 'siteName' ] = $ this -> siteName ; Yii :: app ( ) -> session [ 'primaryEmail' ] = $ this -> email ; $ connection = new CDbConnection ( Yii :: app ( ) -> session [ 'dsn' ] [ 'dsn' ] , Yii :: app ( ) -> session [ 'dsn' ] [ 'username' ] , Yii :: app ( ) -> session [ 'dsn' ] [ 'password' ] ) ; $ connection -> setActive ( true ) ; $ connection -> createCommand ( 'INSERT INTO users (id, email, password, username, user_role, status, created, updated) VALUES (1, :email, :password, :username, 9, 1, UNIX_TIMESTAMP(),UNIX_TIMESTAMP())' ) -> bindParam ( ':email' , $ this -> email ) -> bindParam ( ':password' , $ this -> encryptedPassword ) -> bindParam ( ':username' , $ this -> username ) -> execute ( ) ; return true ; } catch ( CDbException $ e ) { $ this -> addError ( 'password' , Yii :: t ( 'Install.main' , 'There was an error saving your details to the database.' ) ) ; return false ; } return false ; }
This method will save the admin user into the database
13,460
public function checkConfigDir ( ) { if ( is_writable ( dirname ( __FILE__ ) . '/../../../config' ) ) return true ; $ this -> addError ( 'isConfigDirWritable' , Yii :: t ( 'Install.main' , 'Configuration directory is not writable. This must be corrected before your settings can be applied.' ) ) ; return false ; }
Validator for checkConfigDir
13,461
public function formatData ( ) { $ this -> formatter -> addData ( $ this -> data ) ; try { $ formatted = $ this -> formatter -> format ( ) ; } catch ( DataException $ e ) { throw new FormattingException ( 'The provided data has been incorrectly formatted.' ) ; } return $ formatted ; }
Calls the Formatter with the data passed into the Request
13,462
function send ( $ contents , $ status = 200 , array $ headers = null ) { $ this -> http_response_code ( $ status ) ; if ( $ headers !== null ) { foreach ( $ headers as $ header ) { $ this -> header ( $ header [ 0 ] , $ header [ 1 ] , $ header [ 2 ] ) ; } } if ( ! empty ( $ contents ) ) { echo $ contents ; } }
Sent content to the client .
13,463
public function createNotFoundException ( $ message = 'Not Found' , \ Exception $ previous = null ) { if ( $ this -> has ( 'atom.404.logger' ) ) { $ log = $ this -> get ( 'atom.404.logger' ) ; $ log -> addRecord ( 400 , $ message , array ( 'request' => $ this -> getRequest ( ) -> getUri ( ) ) ) ; } return new NotFoundHttpException ( $ message , $ previous ) ; }
Sends 404 to Page AtomLogger
13,464
public function index ( $ params = [ ] ) { $ params = ( ! empty ( $ params ) ) ? $ params : $ this -> app -> request -> input ( ) ; $ this -> model -> params = $ params ; $ result = $ this -> model -> search ( $ params ) -> get ( ) ; $ pagination = array_merge ( [ 'records' => $ this -> model -> search ( $ params ) -> count ( ) ] , $ this -> model -> pagination ( ) ) ; return [ 'success' => true , 'paging' => $ pagination , 'data' => $ result ] ; }
Display a listing of the resource
13,465
public function show ( $ id = null ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID' , 400 ) ; } $ item = $ this -> model -> find ( $ id ) ; if ( ! $ item ) { throw new \ Exception ( 'Element not found' , 404 ) ; } return [ 'success' => true , 'data' => $ item ] ; }
Display the specified resource
13,466
public function store ( $ attributes = [ ] ) { $ attributes = ( ! empty ( $ attributes ) ) ? $ attributes : $ this -> app -> request -> input ( ) ; $ result = $ this -> model -> create ( $ attributes ) ; return [ 'success' => true , 'id' => $ result [ 'id' ] , 'data' => $ result ] ; }
Stores a newly created resource in storage
13,467
public function update ( $ id = null , $ attributes = [ ] ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID' , 400 ) ; } $ attributes = ( ! empty ( $ attributes ) ) ? $ attributes : $ this -> app -> request -> input ( ) ; $ result = $ this -> model -> update ( $ id , $ attributes ) ; return [ 'success' => true , 'id' => $ id , 'data' => $ result ] ; }
Update the specified resource in storage
13,468
public function destroy ( $ id = null ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID' , 400 ) ; } $ result = $ this -> model -> destroy ( $ id ) ; return [ 'success' => true , 'id' => $ result ] ; }
Remove the specified resource from storage
13,469
private function addApnsClientsNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'apns' ) ; $ node -> useAttributeAsKey ( 'name' ) -> prototype ( 'array' ) -> children ( ) -> arrayNode ( 'services' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'logger' ) -> defaultValue ( 'logger' ) -> end ( ) -> scalarNode ( 'profiler' ) -> defaultValue ( 'link_value_mobile_notif.profiler.client_profiler' ) -> end ( ) -> end ( ) -> end ( ) -> arrayNode ( 'params' ) -> children ( ) -> scalarNode ( 'endpoint' ) -> cannotBeEmpty ( ) -> defaultValue ( 'tls://gateway.sandbox.push.apple.com:2195' ) -> end ( ) -> scalarNode ( 'ssl_pem_path' ) -> cannotBeEmpty ( ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'ssl_passphrase' ) -> cannotBeEmpty ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; return $ node ; }
Add APNS clients node .
13,470
private function getStatisticSites ( ) { $ result = [ ] ; $ StatistikQuery = new \ SMWPrintRequest ( \ SMWPrintRequest :: PRINT_PROP , "StatistikQuery" , \ SMWPropertyValue :: makeUserProperty ( 'StatistikQuery' ) ) ; $ StatistikTemplate = new \ SMWPrintRequest ( \ SMWPrintRequest :: PRINT_PROP , "StatistikTemplate" , \ SMWPropertyValue :: makeUserProperty ( 'StatistikTemplate' ) ) ; $ pages = QueryUtils :: executeBasicQuery ( '[[Category:Statistik]]' , [ $ StatistikQuery , $ StatistikTemplate ] , [ ] ) ; while ( $ res = $ pages -> getNext ( ) ) { $ pageID = $ res [ 0 ] -> getNextText ( SMW_OUTPUT_WIKI ) ; $ StatistikQuery = $ res [ 1 ] -> getNextText ( SMW_OUTPUT_WIKI ) ; $ StatistikTemplate = $ res [ 2 ] -> getNextText ( SMW_OUTPUT_WIKI ) ; $ mwTitle = \ Title :: newFromText ( $ pageID ) ; $ result [ ] = [ 'title' => $ mwTitle , 'statistikQuery' => urldecode ( $ StatistikQuery ) , 'statistikTemplate' => urldecode ( $ StatistikTemplate ) ] ; } return $ result ; }
Returns array of statistic site with StatistikQuery StatistikTemplate annotations
13,471
public function process ( ContainerBuilder $ container ) { if ( ! $ container -> hasDefinition ( ParserChainInterface :: SERVICE_ID ) ) { return ; } $ definition = $ container -> getDefinition ( ParserChainInterface :: SERVICE_ID ) ; $ taggedServices = $ container -> findTaggedServiceIds ( MediaParserInterface :: SERVICE_TAG ) ; foreach ( $ taggedServices as $ id => $ tagAttributes ) { foreach ( $ tagAttributes as $ attributes ) { $ definition -> addMethodCall ( 'addParser' , array ( new Reference ( $ id ) ) ) ; } } }
Searches for all Audio Parsers that are tagged as stinger_soft . audioparser inside all services . yml files
13,472
public function getDnsName ( ) : string { $ host = $ this -> environment [ "HTTP_HOST" ] ?? "" ; $ port = strpos ( $ host , ":" ) ; if ( $ port !== false ) { return substr ( $ host , 0 , $ port ) ; } return $ host ; }
Retrieve the name of the request host
13,473
public function cmdPermAddRole ( ) { list ( $ role_id , $ existing , $ submitted ) = $ this -> getPermissionsRole ( ) ; $ data = array ( 'permissions' => array_unique ( array_merge ( $ existing , $ submitted ) ) ) ; $ this -> setSubmitted ( null , $ data ) ; $ this -> setSubmitted ( 'update' , $ role_id ) ; $ this -> validateComponent ( 'user_role' ) ; $ this -> updateRole ( $ role_id ) ; $ this -> output ( ) ; }
Callback for role - perm - add command
13,474
public function cmdPermDeleteRole ( ) { list ( $ role_id , $ existing , $ submitted ) = $ this -> getPermissionsRole ( ) ; $ data = array ( 'permissions' => array_unique ( array_diff ( $ existing , $ submitted ) ) ) ; $ this -> setSubmitted ( null , $ data ) ; $ this -> setSubmitted ( 'update' , $ role_id ) ; $ this -> validateComponent ( 'user_role' ) ; $ this -> updateRole ( $ role_id ) ; $ this -> output ( ) ; }
Callback for role - perm - delete command
13,475
public function cmdGetRole ( ) { $ result = $ this -> getListRole ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableRole ( $ result ) ; $ this -> output ( ) ; }
Callback for role - get command
13,476
public function cmdDeleteRole ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ result = $ this -> role -> delete ( $ id ) ; } else if ( $ all ) { $ deleted = $ count = 0 ; foreach ( $ this -> role -> getList ( ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> role -> delete ( $ item [ 'role_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for role - delete command
13,477
public function cmdUpdateRole ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this -> setSubmitted ( null , $ params ) ; $ this -> setSubmittedList ( 'permissions' ) ; $ this -> setSubmitted ( 'update' , $ params [ 0 ] ) ; $ this -> validateComponent ( 'user_role' ) ; $ this -> updateRole ( $ params [ 0 ] ) ; $ this -> output ( ) ; }
Callback for role - update command
13,478
protected function submitAddRole ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmittedList ( 'permissions' ) ; $ this -> validateComponent ( 'user_role' ) ; $ this -> addRole ( ) ; }
Add a new user role at once
13,479
protected function addRole ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> role -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new user role
13,480
protected function wizardAddRole ( ) { $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'user_role' ) ; $ this -> validatePromptList ( 'permissions' , $ this -> text ( 'Permissions' ) , 'user_role' ) ; $ this -> validatePrompt ( 'redirect' , $ this -> text ( 'Redirect' ) , 'user_role' , '' ) ; $ this -> validatePrompt ( 'status' , $ this -> text ( 'Status' ) , 'user_role' , 0 ) ; $ this -> setSubmittedList ( 'permissions' ) ; $ this -> validateComponent ( 'user_role' ) ; $ this -> addRole ( ) ; }
Add a new user role step by step
13,481
public function All ( $ Func ) { $ result = true ; $ Func = new Expression ( $ Func ) ; foreach ( $ this -> repository as $ item ) $ result &= $ Func -> execute ( $ item ) ; return ( boolean ) $ result ; }
Retreive all items with or without condition
13,482
public function Where ( $ Func ) { if ( $ Func != null ) { $ repo = array ( ) ; $ Func = new Expression ( $ Func ) ; foreach ( $ this -> repository as $ item ) if ( $ Func -> execute ( $ item ) ) $ repo [ ] = $ item ; } else { $ repo = $ this -> repository ; } return $ this -> getClone ( ) -> setRepository ( $ repo ) ; }
Filters a sequence of values based on a predicate .
13,483
public function Any ( $ Func ) { $ result = false ; $ Func = new Expression ( $ Func ) ; foreach ( $ this -> repository as $ item ) $ result |= $ Func -> execute ( $ item ) ; return ( boolean ) $ result ; }
Determines whether a sequence contains any elements .
13,484
public function Count ( $ Func = null ) { return $ Func ? $ this -> Where ( $ Func ) -> Count ( ) : count ( $ this -> repository ) ; }
Count repository with or without condition
13,485
public function Average ( $ Func = null ) { $ items = $ this -> Select ( $ Func ) ; $ count = $ items -> Count ( ) ; $ sum = 0 ; foreach ( $ items as $ item ) $ sum += $ item ; return $ sum / $ count ; }
Get Average of sequence
13,486
public function Sum ( $ Func = null ) { $ items = $ this -> Select ( $ Func ) ; $ sum = 0 ; foreach ( $ items as $ item ) $ sum += $ item ; return $ sum ; }
Get sum of sequence
13,487
public function Concat ( $ source ) { $ source = is_array ( $ source ) ? $ source : ( $ source instanceof Queryable ? $ source -> toList ( ) : iterator_to_array ( $ source ) ) ; return $ this -> getClone ( ) -> setRepository ( array_merge ( $ this -> repository , $ source ) ) ; }
Concatenates two sequences .
13,488
public function Except ( $ items ) { return $ this -> getClone ( ) -> setRepository ( array_diff ( $ this -> repository , $ items instanceof Queryable ? $ items -> toArray ( ) : $ items ) ) ; }
Produces the set difference of two sequences by using the default equality comparer to compare values .
13,489
public function First ( $ Func = null , $ default = null ) { $ bag = $ Func ? $ this -> Select ( $ Func ) : $ this -> repository ; return current ( $ bag ) ? : $ default ; }
Get first element of sequence with or without condition
13,490
public function SelectKeyValue ( $ Key , $ Value ) { $ Key = new Expression ( $ Key ) ; $ Value = new Expression ( $ Value ) ; $ items = array ( ) ; foreach ( $ this -> repository as $ item ) { $ _k = $ Key -> execute ( $ item ) ; $ _v = $ Value -> execute ( $ item ) ; $ items [ $ _k ] = $ _v ; } return new Queryable ( $ items ) ; }
Select key value
13,491
public function Intersect ( $ items ) { return $ this -> getClone ( ) -> setRepository ( array_intersect ( $ this -> repository , $ items instanceof Queryable ? $ items -> toArray ( ) : $ items ) ) ; }
Get Intersect of two sequence
13,492
public function Cast ( $ type ) { $ obj = $ this -> getClone ( ) ; foreach ( $ obj -> repository as & $ value ) { settype ( $ value , $ type ) ; } return $ obj ; }
Casts the elements to the specified type .
13,493
public function Sort ( $ Func = null ) { $ sorted = $ this -> repository ; $ Func = new Expression ( $ Func ) ; usort ( $ sorted , [ $ Func , 'execute' ] ) ; return $ this -> getClone ( ) -> setRepository ( $ sorted ) ; }
Sort sequence by given comparator
13,494
public static function compare ( $ string , $ value , $ length = 0 ) { $ string = ( string ) $ string ; $ value = ( string ) $ value ; if ( $ length > 0 ) { return strncasecmp ( $ string , $ value , $ length ) ; } return strcasecmp ( $ string , $ value ) ; }
Compares to strings alphabetically . Returns 0 if they are equal negative if passed value is greater or positive if current value is greater .
13,495
public static function contains ( $ string , $ needle , $ strict = true , $ offset = 0 ) { return ( static :: indexOf ( $ string , $ needle , $ strict , $ offset ) !== false ) ; }
Check to see if a string exists within this string .
13,496
public static function endsWith ( $ string , $ needle , $ strict = true ) { $ end = static :: extract ( $ string , - mb_strlen ( $ needle ) ) ; if ( $ strict ) { return ( $ end === $ needle ) ; } return ( mb_strtolower ( $ end ) === mb_strtolower ( $ needle ) ) ; }
Checks to see if the string ends with a specific value .
13,497
public static function extract ( $ string , $ offset , $ length = null ) { if ( $ length ) { return mb_substr ( $ string , $ offset , $ length ) ; } return mb_substr ( $ string , $ offset ) ; }
Extracts a portion of a string .
13,498
public static function indexOf ( $ string , $ needle , $ strict = true , $ offset = 0 ) { if ( $ strict ) { return mb_strpos ( $ string , $ needle , $ offset ) ; } return mb_stripos ( $ string , $ needle , $ offset ) ; }
Grab the index of the first matched character .
13,499
public static function insert ( $ string , array $ data , array $ options = array ( ) ) { $ options = $ options + array ( 'before' => '{' , 'after' => '}' , 'escape' => true ) ; foreach ( $ data as $ key => $ value ) { $ string = str_replace ( $ options [ 'before' ] . $ key . $ options [ 'after' ] , $ value , $ string ) ; } if ( $ options [ 'escape' ] ) { $ string = Sanitize :: escape ( $ string ) ; } return $ string ; }
Insert values into a string defined by an array of key tokens .