idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
16,600
public function get ( $ object ) { $ hash = spl_object_hash ( $ object ) ; if ( isset ( $ this -> data [ $ hash ] ) ) { return $ this -> data [ $ hash ] ; } return null ; }
Returns the data associated to the given object .
16,601
public function set ( $ object , $ data = null ) : void { $ hash = spl_object_hash ( $ object ) ; $ this -> objects [ $ hash ] = $ object ; $ this -> data [ $ hash ] = $ data ; }
Stores an object with associated data .
16,602
public function remove ( $ object ) : void { $ hash = spl_object_hash ( $ object ) ; unset ( $ this -> objects [ $ hash ] ) ; unset ( $ this -> data [ $ hash ] ) ; }
Removes the given object from this storage along with associated data .
16,603
public function getIterator ( ) : \ Traversable { foreach ( $ this -> objects as $ hash => $ object ) { yield $ object => $ this -> data [ $ hash ] ; } }
Returns an iterator for this storage .
16,604
public function call ( $ reqData ) { $ respData = $ this -> createError ( 'Unrecognized entity or action' ) ; if ( $ reqData [ 'entity' ] == 'Cxn' && preg_match ( '/^[a-zA-Z]+$/' , $ reqData [ 'action' ] ) ) { $ func = 'on' . $ reqData [ 'entity' ] . strtoupper ( $ reqData [ 'action' ] { 0 } ) . substr ( $ reqData [ 'a...
Delegate handling of hte registration message to a callback function .
16,605
public function onCxnRegister ( $ cxn , $ params ) { $ storedCxn = $ this -> cxnStore -> getByCxnId ( $ cxn [ 'cxnId' ] ) ; if ( ! $ storedCxn || $ storedCxn [ 'secret' ] == $ cxn [ 'secret' ] ) { $ this -> log -> notice ( 'Register cxnId="{cxnId}" siteUrl={siteUrl}: OK' , array ( 'cxnId' => $ cxn [ 'cxnId' ] , 'siteUr...
Callback for Cxn . register .
16,606
public function onCxnUnregister ( $ cxn , $ params ) { $ storedCxn = $ this -> cxnStore -> getByCxnId ( $ cxn [ 'cxnId' ] ) ; if ( ! $ storedCxn ) { $ this -> log -> warning ( 'Unregister cxnId="{cxnId} siteUrl="{siteUrl}"": Non-existent' , array ( 'cxnId' => $ cxn [ 'cxnId' ] , 'siteUrl' => $ cxn [ 'siteUrl' ] , ) ) ;...
Callback for Cxn . unregister .
16,607
public function addPlugin ( Plugin $ plugin ) : Builder { $ this -> plugins [ ] = $ plugin ; $ this -> httpClientModified = true ; return $ this ; }
Add a new plugin to the end of the plugin chain .
16,608
public static function set ( $ method , $ path , $ action ) { if ( is_array ( $ method ) ) { foreach ( $ method as $ value ) { self :: set ( $ value , $ path , $ action ) ; } } else { if ( is_string ( $ action ) ) { $ action = parent :: $ prefixNS . $ action ; } elseif ( $ action !== null && ! $ action instanceof \ Clo...
Register or remove a action from controller for a route
16,609
public static function get ( ) { if ( self :: $ current !== null ) { return self :: $ current ; } $ resp = 404 ; $ args = array ( ) ; $ routes = parent :: $ httpRoutes ; $ path = \ UtilsPath ( ) ; $ method = $ _SERVER [ 'REQUEST_METHOD' ] ; if ( isset ( $ routes [ $ path ] ) ) { $ verbs = $ routes [ $ path ] ; } else {...
Get action controller from current route
16,610
public static function run ( callable $ function ) { set_error_handler ( static function ( $ severity , $ message , $ file , $ line ) { throw new \ ErrorException ( $ message , 0 , $ severity , $ file , $ line ) ; } ) ; try { $ result = $ function ( ) ; } finally { restore_error_handler ( ) ; } return $ result ; }
Runs the given function catching PHP errors and throwing exceptions .
16,611
public static function emergency ( $ message , $ context = [ ] , $ channel = 'tastphp.logger' ) { $ logger = static :: getLoggerByLevelAndChannel ( Monolog :: ALERT , $ channel ) ; $ logger -> addEmergency ( $ message , $ context ) ; }
system is unusable .
16,612
public static function dispatch ( ) { if ( empty ( self :: $ headers ) === false ) { self :: $ dispatchedHeaders = true ; foreach ( self :: $ headers as $ value ) { self :: putHeader ( $ value [ 0 ] , $ value [ 1 ] , $ value [ 2 ] ) ; } } }
Define registered headers to response
16,613
public static function status ( $ code = null , $ trigger = true ) { if ( self :: $ httpCode === null ) { self :: $ httpCode = \ UtilsStatusCode ( ) ; } if ( $ code === null || self :: $ httpCode === $ code ) { return self :: $ httpCode ; } elseif ( headers_sent ( ) || $ code < 100 || $ code > 599 ) { return false ; } ...
Get or set status code and return last status code
16,614
public static function removeHeader ( $ name ) { self :: $ headers = array_filter ( self :: $ headers , function ( $ header ) use ( $ name ) { return strcasecmp ( $ header [ 0 ] , $ name ) !== 0 ; } ) ; }
Remove registered header
16,615
public static function download ( $ name = null , $ contentLength = 0 ) { if ( $ name ) { $ name = '; filename="' . strtr ( $ name , '"' , '-' ) . '"' ; } else { $ name = '' ; } self :: putHeader ( 'Content-Transfer-Encoding' , 'Binary' ) ; self :: putHeader ( 'Content-Disposition' , 'attachment' . $ name ) ; if ( $ co...
Force download current page
16,616
public function addViewData ( $ key , $ value ) { if ( $ key ) { $ this -> modelVar [ $ key ] = $ value ; } else { $ this -> modelVar = $ value ; } return $ this ; }
to add view data
16,617
public function inputObserver ( $ callback , $ exitCicle = null ) { if ( self :: isCli ( ) === false || is_callable ( $ callback ) === false ) { return false ; } $ this -> io = $ callback ; $ this -> ec = $ exitCicle ? $ exitCicle : $ this -> ec ; if ( $ this -> started ) { return true ; } $ this -> started = true ; $ ...
Add callback event to input
16,618
protected function fireInputObserver ( ) { $ response = rtrim ( self :: input ( ) , PHP_EOL ) ; if ( strcasecmp ( $ response , $ this -> ec ) === 0 ) { return null ; } $ callback = $ this -> io ; $ callback ( $ response ) ; usleep ( 100 ) ; $ this -> fireInputObserver ( ) ; }
Trigger observer input
16,619
public function get ( string $ pattern , callable $ callback ) { if ( $ this -> requestMethod === "GET" ) { $ this -> mapRoute ( $ pattern , $ callback ) ; } }
allow to access via the get request
16,620
public function post ( string $ pattern , callable $ callback ) { if ( $ this -> requestMethod === "POST" ) { $ this -> mapRoute ( $ pattern , $ callback ) ; } }
allow to access via the post request
16,621
private static function getPattern ( string $ pattern ) { $ keywords = preg_split ( "/\\//" , $ pattern ) ; $ i = '0' ; $ word = "" ; foreach ( $ keywords as $ keyword ) { $ i ++ ; if ( preg_match ( "/:/i" , $ keyword ) ) { $ word .= "([a-zA-Z0-9-._]+)" ; } else { $ word .= $ keyword ; } if ( count ( $ keywords ) != $ ...
input patten re change
16,622
private function normalizeConfig ( array $ embedConfig ) { $ config = $ embedConfig ; if ( array_key_exists ( 'video_player' , $ embedConfig ) ) { $ config [ 'video' ] [ 'player' ] = $ embedConfig [ 'video_player' ] ; } if ( array_key_exists ( 'video_autoplay' , $ embedConfig ) ) { $ config [ 'video' ] [ 'autoplay' ] =...
apply deprecated configuration keys
16,623
public function group ( $ group , $ handle = null , $ content = null ) { $ this -> groups [ $ group ] [ $ handle ] = $ content ; return $ this ; }
Group wrapper .
16,624
public function removeGroup ( $ group = null , $ handle = null ) { if ( is_null ( $ group ) ) { return $ this -> groups = [ ] ; } if ( is_null ( $ handle ) ) { unset ( $ this -> groups [ $ group ] ) ; return ; } unset ( $ this -> groups [ $ group ] [ $ handle ] ) ; }
Remove a group asset all of a groups assets or all group assets .
16,625
public function renderGroup ( $ group ) { if ( ! isset ( $ this -> groups [ $ group ] ) ) { return PHP_EOL ; } foreach ( $ this -> groups [ $ group ] as $ handle => $ data ) { $ assets [ ] = $ this -> getGroup ( $ group , $ handle ) ; } return implode ( PHP_EOL , $ assets ) ; }
Get all of a groups assets sorted by dependencies .
16,626
public function saveSeoContent ( ) { $ model = $ this -> getSeoContentModel ( ) ; if ( ! $ model -> is_global ) { $ model -> title = $ this -> owner -> { $ this -> titleAttribute } ; $ model -> keywords = $ this -> owner -> { $ this -> keywordsAttribute } ; $ model -> description = $ this -> owner -> { $ this -> descri...
Saving seo content
16,627
public function deleteSeoContent ( ) { $ model = $ this -> getSeoContentModel ( ) ; if ( $ model && ! $ model -> getIsNewRecord ( ) && ! $ model -> is_global ) { $ model -> delete ( ) ; } }
Deleting seo content
16,628
protected static function find ( $ route , $ path , array & $ matches ) { $ re = Regex :: parse ( $ route ) ; if ( $ re !== false && preg_match ( '#^' . $ re . '$#' , $ path , $ matches ) ) { array_shift ( $ matches ) ; return true ; } return false ; }
Get params from routes using regex
16,629
private static function verbs ( array $ methods ) { $ list = array ( ) ; $ reMatch = '#^(any|get|post|patch|put|head|delete|options|trace|connect)([A-Z0-9]\w+)$#' ; foreach ( $ methods as $ value ) { $ verb = array ( ) ; if ( preg_match ( $ reMatch , $ value , $ verb ) ) { if ( strcasecmp ( 'index' , $ verb [ 2 ] ) ===...
Extract valid methods
16,630
public function prepare ( ) { if ( $ this -> ready ) { return null ; } $ this -> ready = true ; $ format = $ this -> format ; $ controller = $ this -> controller ; foreach ( $ this -> classMethods as $ value ) { if ( $ format === self :: BOTH || $ format === self :: SLASH ) { $ route = '/' . ( empty ( $ value [ 1 ] ) ?...
Create routes by configurations
16,631
public static function authenticateThenDecrypt ( $ secret , $ body , $ signature ) { $ keys = self :: deriveAesKeys ( $ secret ) ; $ localHmac = hash_hmac ( 'sha256' , $ body , $ keys [ 'auth' ] ) ; if ( ! self :: hash_compare ( $ signature , $ localHmac ) ) { throw new InvalidMessageException ( "Incorrect hash" ) ; } ...
Validate the signature and date of the message then decrypt it .
16,632
private static function hash_compare ( $ a , $ b ) { if ( ! is_string ( $ a ) || ! is_string ( $ b ) ) { return FALSE ; } $ len = strlen ( $ a ) ; if ( $ len !== strlen ( $ b ) ) { return FALSE ; } $ status = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ status |= ord ( $ a [ $ i ] ) ^ ord ( $ b [ $ i ] ) ; } return $...
Comparison function which resists timing attacks .
16,633
public static function exists ( $ path ) { if ( file_exists ( $ path ) === false ) { return false ; } $ path = preg_replace ( '#^file:/+([a-z]:/|/)#i' , '$1' , $ path ) ; $ pinfo = pathinfo ( $ path ) ; $ rpath = strtr ( realpath ( $ path ) , '\\' , '/' ) ; if ( $ pinfo [ 'dirname' ] !== '.' ) { $ path = Uri :: canonpa...
Check if file exists using case - sensitive For help developers who using Windows OS and using unix - like for production
16,634
public static function mime ( $ path ) { $ mime = false ; if ( is_readable ( $ path ) ) { if ( function_exists ( 'finfo_open' ) ) { $ buffer = file_get_contents ( $ path , false , null , - 1 , 5012 ) ; $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_buffer ( $ finfo , $ buffer ) ; finfo_close ( $ finfo ) ;...
Get mimetype from file return false if file is invalid
16,635
public static function output ( $ path , $ length = 102400 , $ delay = 0 ) { if ( is_readable ( $ path ) === false ) { return false ; } $ buffer = ob_get_level ( ) !== 0 ; $ handle = fopen ( $ path , 'rb' ) ; $ length = is_int ( $ length ) && $ length > 0 ? $ length : 102400 ; while ( false === feof ( $ handle ) ) { ec...
Show file in output if use ob_start is auto used ob_flush . You can set delay for cycles
16,636
public function send ( ) { list ( $ headers , $ blob , $ code ) = $ this -> toHttp ( ) ; header ( 'Content-Type: ' . Constants :: MIME_TYPE ) ; header ( "X-PHP-Response-Code: $code" , TRUE , $ code ) ; foreach ( $ headers as $ n => $ v ) { header ( "$n: $v" ) ; } echo $ blob ; }
Send this message immediately .
16,637
public function toSymfonyResponse ( ) { $ headers = array_merge ( array ( 'Content-Type' => Constants :: MIME_TYPE ) , $ this -> getHeaders ( ) ) ; return new \ Symfony \ Component \ HttpFoundation \ Response ( $ this -> encode ( ) , $ this -> code , $ headers ) ; }
Convert this message a Symfony Response object .
16,638
protected function doParse ( $ className , $ visited = array ( ) , array $ groups = array ( ) ) { $ meta = $ this -> factory -> getMetadataForClass ( $ className ) ; if ( null === $ meta ) { throw new \ InvalidArgumentException ( sprintf ( 'No metadata found for class %s' , $ className ) ) ; } $ exclusionStrategies = a...
Recursively parse all metadata for a class .
16,639
public static function header ( $ name = null ) { if ( self :: $ reqHeaders === null ) { self :: generate ( ) ; } if ( is_string ( $ name ) ) { $ name = strtolower ( $ name ) ; return isset ( self :: $ reqHeadersLower [ $ name ] ) ? self :: $ reqHeadersLower [ $ name ] : false ; } return self :: $ reqHeaders ; }
Get HTTP headers from current request
16,640
public static function raw ( $ binary = true ) { if ( is_readable ( 'php://input' ) ) { return false ; } $ mode = $ binary ? 'rb' : 'r' ; if ( PHP_VERSION_ID >= 50600 ) { return fopen ( 'php://input' , $ mode ) ; } $ tmp = Storage :: temp ( ) ; return copy ( 'php://input' , $ tmp ) ? fopen ( $ tmp , $ mode ) : false ; ...
Get a value input handler
16,641
protected static function behavior ( Component $ model ) { foreach ( $ model -> getBehaviors ( ) as $ b ) { if ( $ b instanceof SeoBehavior ) { return $ b ; } } throw new InvalidConfigException ( 'Model ' . $ model -> className ( ) . ' must have SeoBehavior' ) ; }
Getting behavior object from given model
16,642
protected static function registerSeoMetaTag ( Component $ model , string $ modelSeoAttributeName , string $ metaTagKey ) { $ value = $ model -> { $ modelSeoAttributeName } ; if ( $ value ) Yii :: $ app -> view -> registerMetaTag ( [ 'name' => $ metaTagKey , 'content' => $ value ] , $ metaTagKey ) ; }
Register seo meta tag
16,643
public static function registerAllSeoMeta ( Component $ model ) { self :: registerMetaTitle ( $ model ) ; self :: registerMetaKeywords ( $ model ) ; self :: registerMetaDescription ( $ model ) ; }
Register seo metadata . You can register part of it using methods below right in view code .
16,644
public static function setTitle ( Component $ model ) { $ title = $ model -> { self :: behavior ( $ model ) -> titleAttribute } ; if ( $ title ) Yii :: $ app -> view -> title = $ title ; }
Sets page title . If your layout
16,645
public static function registerMetaTitle ( Component $ model ) { $ modelSeoAttributeName = self :: behavior ( $ model ) -> titleAttribute ; self :: registerSeoMetaTag ( $ model , $ modelSeoAttributeName , 'title' ) ; }
Register meta title
16,646
public static function registerMetaKeywords ( Component $ model ) { $ modelSeoAttributeName = self :: behavior ( $ model ) -> keywordsAttribute ; self :: registerSeoMetaTag ( $ model , $ modelSeoAttributeName , 'keywords' ) ; }
Register meta keywords
16,647
public static function registerMetaDescription ( Component $ model ) { $ modelSeoAttributeName = self :: behavior ( $ model ) -> descriptionAttribute ; self :: registerSeoMetaTag ( $ model , $ modelSeoAttributeName , 'description' ) ; }
Register meta description
16,648
public function gets ( ? int $ maxLength = null ) : string { if ( $ this -> closed ) { throw new IoException ( 'The stream is closed.' ) ; } try { $ data = ErrorCatcher :: run ( function ( ) use ( $ maxLength ) { if ( $ maxLength === null ) { return fgets ( $ this -> handle ) ; } else { return fgets ( $ this -> handle ...
Reads a line from the stream .
16,649
public function lock ( bool $ exclusive ) : void { if ( $ this -> closed ) { throw new IoException ( 'The stream is closed.' ) ; } try { $ result = ErrorCatcher :: run ( function ( ) use ( $ exclusive ) { return flock ( $ this -> handle , $ exclusive ? LOCK_EX : LOCK_SH ) ; } ) ; } catch ( \ ErrorException $ e ) { thro...
Obtains an advisory lock .
16,650
public function unlock ( ) : void { if ( $ this -> closed ) { throw new IoException ( 'The stream is closed.' ) ; } try { $ result = ErrorCatcher :: run ( function ( ) { return flock ( $ this -> handle , LOCK_UN ) ; } ) ; } catch ( \ ErrorException $ e ) { throw new IoException ( $ e -> getMessage ( ) , 0 , $ e ) ; } i...
Releases an advisory lock .
16,651
public function withScheme ( $ scheme ) { $ scheme = strtolower ( $ scheme ) ; $ pattern = new UriPattern ( ) ; if ( strlen ( $ scheme ) === 0 || $ pattern -> matchScheme ( $ scheme ) ) { return $ this -> with ( 'scheme' , $ scheme ) ; } throw new \ InvalidArgumentException ( "Invalid scheme '$scheme'" ) ; }
Returns a URI instance with the specified scheme .
16,652
public function withUserInfo ( $ user , $ password = null ) { $ username = rawurlencode ( $ user ) ; if ( strlen ( $ username ) > 0 ) { return $ this -> with ( 'userInfo' , $ this -> constructString ( [ '%s%s' => $ username , '%s:%s' => rawurlencode ( $ password ) , ] ) ) ; } return $ this -> with ( 'userInfo' , '' ) ;...
Returns a URI instance with the specified user information .
16,653
public function withHost ( $ host ) { $ pattern = new UriPattern ( ) ; if ( $ pattern -> matchHost ( $ host ) ) { return $ this -> with ( 'host' , $ this -> normalize ( strtolower ( $ host ) ) ) ; } throw new \ InvalidArgumentException ( "Invalid host '$host'" ) ; }
Returns a URI instance with the specified host .
16,654
public function withPort ( $ port ) { if ( $ port !== null ) { $ port = ( int ) $ port ; if ( max ( 0 , min ( 65535 , $ port ) ) !== $ port ) { throw new \ InvalidArgumentException ( "Invalid port number '$port'" ) ; } } return $ this -> with ( 'port' , $ port ) ; }
Returns a URI instance with the specified port .
16,655
private function with ( $ variable , $ value ) { if ( $ value === $ this -> $ variable ) { return $ this ; } $ uri = clone $ this ; $ uri -> $ variable = $ value ; return $ uri ; }
Returns an Uri instance with the given value .
16,656
private function encode ( $ string , $ extra = '' ) { $ pattern = sprintf ( '/[^0-9a-zA-Z%s]|%%(?![0-9A-F]{2})/' , preg_quote ( "%-._~!$&'()*+,;=" . $ extra , '/' ) ) ; return preg_replace_callback ( $ pattern , function ( $ match ) { return sprintf ( '%%%02X' , ord ( $ match [ 0 ] ) ) ; } , $ this -> normalize ( $ str...
Percent encodes the value without double encoding .
16,657
private function constructString ( array $ components ) { $ formats = array_keys ( $ components ) ; $ values = array_values ( $ components ) ; $ keys = array_keys ( array_filter ( $ values , 'strlen' ) ) ; return array_reduce ( $ keys , function ( $ string , $ key ) use ( $ formats , $ values ) { return sprintf ( $ for...
Constructs the string from the non empty parts with specific formats .
16,658
private function getNormalizedUriPath ( ) { $ path = $ this -> getPath ( ) ; if ( $ this -> getAuthority ( ) === '' ) { return preg_replace ( '#^/+#' , '/' , $ path ) ; } elseif ( $ path === '' || $ path [ 0 ] === '/' ) { return $ path ; } return '/' . $ path ; }
Returns the path normalized for the string representation .
16,659
public function hGet ( $ hashKey , $ key ) { $ value = $ this -> redis -> hGet ( $ hashKey , $ key ) ; if ( $ value ) { $ value = gzinflate ( $ value ) ; } $ jsonData = json_decode ( $ value , true ) ; return ( $ jsonData === NULL ) ? $ value : $ jsonData ; }
get hash cache
16,660
public function hSet ( $ hashKey , $ key , $ data , $ expireTime = 3600 ) { $ data = ( is_object ( $ data ) || is_array ( $ data ) ) ? json_encode ( $ data ) : $ data ; $ data = gzdeflate ( $ data , 0 ) ; if ( strlen ( $ data ) > 4096 ) { $ data = gzdeflate ( $ data , 6 ) ; } $ status = $ this -> redis -> hSet ( $ hash...
set hash cache
16,661
public function header ( $ header , $ level = self :: HIGH ) { $ header = strtolower ( $ header ) ; if ( empty ( $ this -> headers [ $ header ] ) ) { return false ; } return self :: qFactor ( $ this -> headers [ $ header ] , $ level ) ; }
Parse any header like TE header or headers with Accepet - prefix
16,662
public static function qFactor ( $ value , $ level = self :: HIGH ) { $ multivalues = explode ( ',' , $ value ) ; $ headers = array ( ) ; foreach ( $ multivalues as $ hvalues ) { if ( substr_count ( $ hvalues , ';' ) > 1 ) { throw new Exception ( 'Header contains a value with multiple semicolons: "' . $ value . '"' , 2...
Parse and sort a custom value with q - factor
16,663
public function joinCondition ( ) { if ( ! isset ( $ this -> _joinCondition ) ) { $ this -> _joinCondition = Factory :: filter ( $ this ) ; } return $ this -> _joinCondition ; }
The filter used for the ON clause of a JOIN
16,664
public static function portion ( $ path , $ init = 0 , $ end = 1024 , $ lines = false ) { self :: fullpath ( $ path ) ; if ( $ lines !== true ) { return file_get_contents ( $ path , false , null , $ init , $ end ) ; } $ i = 1 ; $ output = '' ; $ handle = fopen ( $ path , 'rb' ) ; while ( false === feof ( $ handle ) && ...
Read a script excerpt
16,665
public static function isBinary ( $ path ) { self :: fullpath ( $ path ) ; $ size = filesize ( $ path ) ; if ( $ size >= 0 && $ size < 2 ) { return false ; } $ finfo = finfo_open ( FILEINFO_MIME_ENCODING ) ; $ encode = finfo_buffer ( $ finfo , file_get_contents ( $ path , false , null , 0 , 5012 ) ) ; finfo_close ( $ f...
Determines whether the file is binary
16,666
public static function size ( $ path ) { $ path = ltrim ( self :: fullpath ( $ path ) , '/' ) ; $ ch = curl_init ( 'file://' . $ path ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HEADER , true ) ; curl_setopt ( $ ch , CURLOPT_NOBODY , true ) ; $ headers = curl_exec ( $ ch ) ; ...
Get file size support for read files with more of 2GB in 32bit . Return false if file is not found
16,667
public function get ( $ selector , \ DOMNode $ context = null , $ registerNodeNS = true ) { return $ this -> exec ( 'query' , $ selector , $ context , $ registerNodeNS ) ; }
Returns a \ DOMNodeList containing all nodes matching the given CSS selector
16,668
public function isRunning ( Datetime $ current = null ) { $ current = $ current ? : new Datetime ; return $ this -> hasStarted ( $ current ) && ! $ this -> hasEnded ( $ current ) ; }
Checks if this event is currently running
16,669
public function detach ( ) { $ this -> calendar -> getEvents ( ) -> removeEvent ( $ this ) ; $ this -> calendar = null ; return $ this ; }
Detach this event from the associated Calendar
16,670
public function validateCert ( $ certPem ) { if ( $ this -> getCaCert ( ) ) { self :: validate ( $ certPem , $ this -> getCaCert ( ) , $ this -> getCrl ( ) , $ this -> getCrlDistCert ( ) ) ; } }
Determine whether an X . 509 certificate is currently valid .
16,671
public function getCrlUrl ( ) { if ( $ this -> crlUrl === self :: AUTOLOAD ) { $ this -> crlUrl = NULL ; $ caCertObj = X509Util :: loadCACert ( $ this -> getCaCert ( ) ) ; $ crlDPs = $ caCertObj -> getExtension ( 'id-ce-cRLDistributionPoints' ) ; if ( is_array ( $ crlDPs ) ) { foreach ( $ crlDPs as $ crlDP ) { foreach ...
Determine the CRL URL which corresponds to this CA .
16,672
public function matchUri ( $ uri , & $ matches = [ ] ) { if ( $ this -> matchAbsoluteUri ( $ uri , $ matches ) ) { return true ; } return $ this -> matchRelativeUri ( $ uri , $ matches ) ; }
Matches the string against URI or relative - ref ABNF .
16,673
private function match ( $ pattern , $ subject , & $ matches ) { $ matches = [ ] ; $ subject = ( string ) $ subject ; if ( $ this -> allowNonAscii || preg_match ( '/^[\\x00-\\x7F]*$/' , $ subject ) ) { if ( preg_match ( $ pattern , $ subject , $ match ) ) { $ matches = $ this -> getNamedPatterns ( $ match ) ; return tr...
Matches the subject against the pattern and provides the literal sub patterns .
16,674
private function getNamedPatterns ( $ matches ) { foreach ( $ matches as $ key => $ value ) { if ( ! is_string ( $ key ) || strlen ( $ value ) < 1 ) { unset ( $ matches [ $ key ] ) ; } } return $ matches ; }
Returns nonempty named sub patterns from the match set .
16,675
private static function buildPatterns ( ) { $ alpha = 'A-Za-z' ; $ digit = '0-9' ; $ hex = $ digit . 'A-Fa-f' ; $ unreserved = "$alpha$digit\\-._~" ; $ delimiters = "!$&'()*+,;=" ; $ utf8 = '\\x80-\\xFF' ; $ octet = "(?:[$digit]|[1-9][$digit]|1[$digit]{2}|2[0-4]$digit|25[0-5])" ; $ ipv4address = "(?>$octet\\.$octet\\.$...
Builds the PCRE patterns according to the ABNF definitions .
16,676
public static function createDirectories ( string $ path , int $ mode = 0777 ) : void { $ exception = null ; try { $ success = ErrorCatcher :: run ( static function ( ) use ( $ path , $ mode ) { return mkdir ( $ path , $ mode , true ) ; } ) ; if ( $ success === true ) { return ; } } catch ( \ ErrorException $ e ) { $ e...
Creates a directory by creating all nonexistent parent directories first .
16,677
public static function isFile ( string $ path ) : bool { try { return ErrorCatcher :: run ( static function ( ) use ( $ path ) { return is_file ( $ path ) ; } ) ; } catch ( \ ErrorException $ e ) { throw new IoException ( 'Error checking if ' . $ path . ' is a file' , 0 , $ e ) ; } }
Checks whether the path points to a regular file .
16,678
public static function isDirectory ( string $ path ) : bool { try { return ErrorCatcher :: run ( static function ( ) use ( $ path ) { return is_dir ( $ path ) ; } ) ; } catch ( \ ErrorException $ e ) { throw new IoException ( 'Error checking if ' . $ path . ' is a directory' , 0 , $ e ) ; } }
Checks whether the path points to a directory .
16,679
public static function isSymbolicLink ( string $ path ) : bool { try { return ErrorCatcher :: run ( static function ( ) use ( $ path ) { return is_link ( $ path ) ; } ) ; } catch ( \ ErrorException $ e ) { throw new IoException ( 'Error checking if ' . $ path . ' is a symbolic link' , 0 , $ e ) ; } }
Checks whether the path points to a symbolic link .
16,680
public static function createSymbolicLink ( string $ link , string $ target ) : void { $ exception = null ; try { $ success = ErrorCatcher :: run ( static function ( ) use ( $ link , $ target ) { return symlink ( $ target , $ link ) ; } ) ; if ( $ success === true ) { return ; } } catch ( \ ErrorException $ e ) { $ exc...
Creates a symbolic link to a target .
16,681
public static function readSymbolicLink ( string $ path ) : string { $ exception = null ; try { $ result = ErrorCatcher :: run ( static function ( ) use ( $ path ) { return readlink ( $ path ) ; } ) ; if ( $ result !== false ) { return $ result ; } } catch ( \ ErrorException $ e ) { $ exception = $ e ; } throw new IoEx...
Returns the target of a symbolic link .
16,682
public static function getRealPath ( string $ path ) : string { $ exception = null ; try { $ result = ErrorCatcher :: run ( static function ( ) use ( $ path ) { return realpath ( $ path ) ; } ) ; if ( $ result !== false ) { return $ result ; } } catch ( \ ErrorException $ e ) { $ exception = $ e ; } throw new IoExcepti...
Returns the canonicalized absolute pathname .
16,683
public static function write ( string $ path , $ data , bool $ append = false , bool $ lock = false ) : int { $ flags = 0 ; if ( $ append ) { $ flags |= FILE_APPEND ; } if ( $ lock ) { $ flags |= LOCK_EX ; } $ exception = null ; try { $ result = ErrorCatcher :: run ( static function ( ) use ( $ path , $ data , $ flags ...
Writes data to a file .
16,684
public static function read ( string $ path , int $ offset = 0 , int $ maxLength = null ) : string { $ exception = null ; try { $ result = ErrorCatcher :: run ( static function ( ) use ( $ path , $ offset , $ maxLength ) { if ( $ maxLength === null ) { return file_get_contents ( $ path , false , null , $ offset ) ; } r...
Reads data from a file .
16,685
public function getInfo ( int $ opt = null ) { if ( $ opt === null ) { return curl_getinfo ( $ this -> curl ) ; } return curl_getinfo ( $ this -> curl , $ opt ) ; }
Returns information about the last transfer .
16,686
public function parse ( $ uri ) { if ( ! $ this -> isValidString ( $ uri ) ) { return null ; } $ pattern = new UriPattern ( ) ; $ pattern -> allowNonAscii ( $ this -> mode !== self :: MODE_RFC3986 ) ; if ( $ pattern -> matchUri ( $ uri , $ match ) ) { try { return $ this -> buildUri ( $ match ) ; } catch ( \ InvalidArg...
Parses the URL using the generic URI syntax .
16,687
private function isValidString ( $ uri ) { if ( preg_match ( '/^[\\x00-\\x7F]*$/' , $ uri ) ) { return true ; } elseif ( $ this -> mode === self :: MODE_RFC3986 ) { return false ; } $ pattern = '/^(?> [\x00-\x7F]+ # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overl...
Tells if the URI string is valid for the current parser mode .
16,688
private function buildUri ( array $ components ) { $ uri = new Uri ( ) ; if ( isset ( $ components [ 'reg_name' ] ) ) { $ components [ 'host' ] = $ this -> decodeHost ( $ components [ 'host' ] ) ; } foreach ( array_intersect_key ( self :: $ setters , $ components ) as $ key => $ method ) { $ uri = call_user_func ( [ $ ...
Builds the Uri instance from the parsed components .
16,689
private function decodeHost ( $ hostname ) { if ( preg_match ( '/^[\\x00-\\x7F]*$/' , $ hostname ) ) { return $ hostname ; } elseif ( $ this -> mode !== self :: MODE_IDNA2003 ) { throw new \ InvalidArgumentException ( "Invalid hostname '$hostname'" ) ; } $ hostname = idn_to_ascii ( $ hostname ) ; if ( $ hostname === fa...
Decodes the hostname component according to parser mode .
16,690
public static function env ( $ key , $ value = null ) { if ( is_string ( $ value ) || is_bool ( $ value ) || is_numeric ( $ value ) ) { self :: $ configs [ $ key ] = $ value ; } elseif ( $ value === null && isset ( self :: $ configs [ $ key ] ) ) { return self :: $ configs [ $ key ] ; } }
Set or get environment value
16,691
public static function config ( $ path ) { $ data = \ UtilsSandboxLoader ( 'application/Config/' . strtr ( $ path , '.' , '/' ) . '.php' ) ; foreach ( $ data as $ key => $ value ) { self :: env ( $ key , $ value ) ; } $ data = null ; }
Set environment variables by config files
16,692
public static function trigger ( $ name , array $ args = array ( ) ) { if ( $ name === 'error' ) { self :: $ state = 5 ; } if ( empty ( self :: $ events [ $ name ] ) ) { return null ; } $ listen = self :: $ events [ $ name ] ; usort ( $ listen , function ( $ a , $ b ) { return $ b [ 1 ] >= $ a [ 1 ] ; } ) ; foreach ( $...
Trigger registered event
16,693
public static function off ( $ name , $ callback = null ) { if ( empty ( self :: $ events [ $ name ] ) ) { return null ; } elseif ( $ callback === null ) { self :: $ events [ $ name ] = array ( ) ; return null ; } $ evts = self :: $ events [ $ name ] ; foreach ( $ evts as $ key => $ value ) { if ( $ value [ 0 ] === $ c...
Unregister 1 or all events
16,694
public static function stop ( $ code , $ msg = null ) { Response :: status ( $ code , false ) && self :: trigger ( 'changestatus' , array ( $ code , $ msg ) ) ; if ( self :: $ state < 4 ) { self :: $ state = 4 ; self :: trigger ( 'finish' ) ; } exit ; }
Stop application send HTTP status
16,695
public static function exec ( ) { if ( self :: $ state > 0 ) { return null ; } self :: $ state = 1 ; self :: trigger ( 'init' ) ; if ( self :: env ( 'maintenance' ) ) { self :: $ state = 4 ; self :: stop ( 503 ) ; } self :: trigger ( 'changestatus' , array ( \ UtilsStatusCode ( ) , null ) ) ; $ resp = Route :: get ( ) ...
Start application using routes
16,696
public function swap ( int $ index1 , int $ index2 ) : void { if ( $ index1 !== $ index2 ) { $ value = $ this [ $ index1 ] ; $ this [ $ index1 ] = $ this [ $ index2 ] ; $ this [ $ index2 ] = $ value ; } }
Swaps two entries in this FixedArray .
16,697
public function shiftUp ( int $ index ) : void { if ( $ index + 1 === $ this -> count ( ) ) { return ; } $ this -> swap ( $ index , $ index + 1 ) ; }
Shifts an entry to the next index .
16,698
public function shiftTo ( int $ index , int $ newIndex ) : void { while ( $ index > $ newIndex ) { $ this -> shiftDown ( $ index ) ; $ index -- ; } while ( $ index < $ newIndex ) { $ this -> shiftUp ( $ index ) ; $ index ++ ; } }
Shifts an entry to an arbitrary index shifting all the entries between those indexes .
16,699
public function padStringFilter ( $ value , $ padCharacter , $ maxLength , $ padType = 'STR_PAD_RIGHT' ) { if ( $ this -> isNullOrEmptyString ( $ padCharacter ) ) { throw new \ InvalidArgumentException ( 'Pad String Filter cannot accept a null value or empty string as its first argument' ) ; } if ( ! is_int ( $ maxLeng...
Pads string on right or left with given padCharacter until string reaches maxLength