idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
231,500 | function route ( $ path = '/' , array $ actions = [ ] , $ method = Router :: ANY_METHOD , $ name = '' ) { $ this -> path ( $ path ) ; $ this -> actions [ $ method ] = $ actions ; $ this -> name = $ name ; return $ this ; } | Set route params |
231,501 | public function connect ( ) { if ( false === $ this -> connection instanceof \ mysqli ) { $ this -> connection = new \ mysqli ( $ this -> data -> host , $ this -> data -> username , $ this -> data -> password , $ this -> data -> db , $ this -> data -> port ) ; if ( $ this -> data -> charset ) { $ this -> connection -> ... | Connect to Mysql server and set charset |
231,502 | public function fetch ( $ type = null ) { if ( null !== $ type && false === is_string ( $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ query ) ) , E_USER_ERROR ) ; } $ results = new ResultSet ( [ ] , $ type ) ; $ copy = functio... | Returns results from statement as an result set |
231,503 | public function query ( $ query , $ params = [ ] ) { if ( false === is_string ( $ query ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ query ) ) , E_USER_ERROR ) ; } if ( null !== $ params && false === is_array ( $ params ) ) { return... | Prepare a raw query |
231,504 | public function multiquery ( $ query , $ params = [ ] ) { if ( true === is_array ( $ query ) ) { $ query = implode ( ";\n" , $ query ) ; } if ( false === is_string ( $ query ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ quer... | Execute a multiquery |
231,505 | public function escape ( $ data ) { if ( null === $ data ) { return $ data ; } if ( false === is_string ( $ data ) && false === is_numeric ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, float or int, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR )... | Escapes string for statement usage |
231,506 | public function close ( ) { if ( false === $ this -> connection instanceof \ mysqli ) { return trigger_error ( 'Connection already closed' ) ; } $ this -> connection -> close ( ) ; return $ this ; } | Closes the database connection |
231,507 | public function getLastErrno ( ) { if ( true === $ this -> connection instanceof \ mysqli ) { $ this -> connect ( ) ; } return $ this -> connection -> errno ; } | Returns the last error number |
231,508 | public function getLastError ( ) { if ( true === $ this -> connection instanceof \ mysqli ) { $ this -> connect ( ) ; } return $ this -> connection -> error ; } | Returns the last error message |
231,509 | private function escapeSemicolon ( $ query , $ params ) { preg_match_all ( '#:((?:[a-zA-Z_])(?:[a-zA-Z0-9-_]+)?)#' , $ query , $ variables ) ; if ( true === isset ( $ variables [ 0 ] ) ) { foreach ( $ variables [ 0 ] as $ index => $ variable ) { if ( false === array_key_exists ( $ variables [ 1 ] [ $ index ] , $ params... | Escape variables bind with a semicolon |
231,510 | private function escapeQuestionmark ( $ query , $ params ) { preg_match_all ( '#([\\\]{0,})(\?)#' , $ query , $ variables ) ; if ( true === isset ( $ variables [ 0 ] ) ) { foreach ( $ variables [ 0 ] as $ index => $ variable ) { if ( strlen ( $ variables [ 1 ] [ $ index ] ) % 2 !== 0 ) { continue ; } if ( false === iss... | Escape variables bind with a question mark |
231,511 | private function executeStatement ( $ stmt ) { if ( true !== $ stmt -> execute ( ) ) { if ( $ this -> getLastErrno ( ) > 0 ) { return trigger_error ( sprintf ( 'A database error occured with error number "%s" and message: "%s"' , $ this -> getLastErrno ( ) , $ this -> getLastError ( ) ) , E_USER_ERROR ) ; } return fals... | Executes one statement |
231,512 | private function parse ( & $ params , & $ query ) { if ( 0 !== count ( array_filter ( array_keys ( $ params ) , 'is_string' ) ) ) { preg_match_all ( '#:((?:[a-zA-Z_])(?:[a-zA-Z0-9-_]+)?)#' , $ query , $ variables ) ; if ( true === isset ( $ variables [ 0 ] ) ) { $ parameters = [ ] ; foreach ( $ variables [ 0 ] as $ ind... | Parse parameters and return it with types |
231,513 | private function bind ( $ stmt ) { $ meta = $ stmt -> result_metadata ( ) ; $ double = [ ] ; $ vars = [ ] ; if ( $ stmt -> field_count > 0 ) { while ( $ field = $ meta -> fetch_field ( ) ) { $ columnname = $ field -> name ; $ { $ columnname } = null ; if ( true === array_key_exists ( $ columnname , $ vars ) ) { $ doubl... | Bind the result to the variables and returns it |
231,514 | public function registerData ( array $ entityData ) { foreach ( $ entityData as $ data ) { $ this -> registerEntity ( $ this -> normalizer -> denormalize ( $ data , $ this -> entityCollection -> getEntityClass ( ) ) ) ; } } | Register given set of data into datastore . |
231,515 | public function registerEntity ( CollectionableInterface $ entity ) { if ( ! is_a ( $ entity , $ this -> entityCollection -> getEntityClass ( ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Only "%s" object allowed into "%s" store, "%s" given.' , $ this -> entityCollection -> getEntityClass ( ) , get_class ( ... | Register a new Collectionable entity into datastore . |
231,516 | public function warmUp ( $ cacheDir ) { $ stepList = $ this -> stepManager -> getStepList ( ) ; if ( null === $ stepList ) { return ; } foreach ( $ stepList as $ stepName => $ step ) { $ stepFinalConfig = $ this -> stepManager -> getResultingConfig ( $ stepName ) ; $ stepFinalConfig = $ this -> stepManager -> normalize... | Writes the workflow proxy cache file . |
231,517 | public function markEmailAsRead ( $ id ) { $ emailMessage = $ this -> model -> find ( $ id ) ; $ emailMessage -> read = 1 ; return $ emailMessage -> save ( ) ; } | Mark an email as read by setting the read field to true |
231,518 | public function markEmailAsSent ( $ id ) { $ emailMessage = $ this -> model -> find ( $ id ) ; $ emailMessage -> sent = 1 ; return $ emailMessage -> save ( ) ; } | Mark an email as sent by setting the sent field to true |
231,519 | public function disc ( string $ storage ) { if ( isset ( $ this -> storage [ $ storage ] ) ) { $ this -> disc = strtolower ( $ storage ) ; return $ this ; } throw new UnknownStorageException ; } | Set default disc storage |
231,520 | protected function _loop ( ) { if ( ! $ this -> _hasParents ( ) ) { return $ this -> _createIteration ( null , null ) ; } $ parent = & $ this -> _getCurrentIterable ( ) ; $ current = $ this -> _createCurrentIteration ( $ parent ) ; if ( $ current -> getKey ( ) === null ) { return $ this -> _backtrackLoop ( ) ; } if ( !... | Advances the iterator and computes the new state . |
231,521 | protected function _backtrackLoop ( ) { $ this -> _popParent ( ) ; if ( ! $ this -> _hasParents ( ) ) { return $ this -> _createIteration ( null , null ) ; } $ parent = & $ this -> _getCurrentIterable ( ) ; $ current = $ this -> _createCurrentIteration ( $ parent ) ; next ( $ parent ) ; if ( $ this -> _isMode ( R :: MO... | Backtracks up one parent yielding the parent or resuming the loop whichever is appropriate . |
231,522 | protected function _pushParent ( & $ parent ) { $ children = & $ this -> _getElementChildren ( $ parent ) ; $ pathSegment = $ this -> _getElementPathSegment ( null , $ parent ) ; $ this -> _pushPathSegment ( $ pathSegment ) ; reset ( $ children ) ; array_unshift ( $ this -> parents , $ children ) ; } | Adds an iterable parent onto the stack . |
231,523 | protected function _createCurrentIteration ( & $ iterable ) { $ key = $ this -> _getCurrentIterableKey ( $ iterable ) ; $ val = $ this -> _getCurrentIterableValue ( $ iterable ) ; $ path = $ this -> _getCurrentPath ( $ key , $ val ) ; return $ this -> _createIteration ( $ key , $ val , $ path ) ; } | Creates an iteration instance for the current state of a given iterable . |
231,524 | protected function _getCurrentPath ( $ key , $ value ) { $ path = $ this -> _getPathSegments ( ) ; $ path [ ] = $ this -> _getElementPathSegment ( $ key , $ value ) ; return array_filter ( $ path ) ; } | Retrieves the current path . |
231,525 | public function sendLogsTo ( LogConsumer $ logConsumer ) { if ( $ logConsumer === $ this ) { throw new LogicException ( 'Operation not allowed' ) ; } while ( ! empty ( $ this -> collectedLogs ) ) { $ log = array_shift ( $ this -> collectedLogs ) ; $ logConsumer -> consumeLog ( $ log [ 'message' ] , $ log [ 'context' ] ... | Send all logs to other LogConsumer . Be aware that logs are removed during this process . |
231,526 | protected function parseTag ( $ line ) { $ tagAndValue = preg_split ( '/\\s/' , $ line , 2 ) ; $ tag = substr ( $ tagAndValue [ 0 ] , 1 ) ; if ( count ( $ tagAndValue ) > 1 ) { $ this -> tags [ $ tag ] [ ] = trim ( $ tagAndValue [ 1 ] ) ; } else { $ this -> tags [ $ tag ] = [ ] ; } } | Parses a line of a doc comment for a tag and its value . The result is stored in the interal tags array . |
231,527 | public function parseRequest ( $ message ) { if ( ! ( $ parts = $ this -> parseMessage ( $ message ) ) ) { return false ; } if ( isset ( $ parts [ 'start_line' ] [ 2 ] ) ) { $ startParts = explode ( '/' , $ parts [ 'start_line' ] [ 2 ] ) ; $ protocol = strtoupper ( $ startParts [ 0 ] ) ; $ version = isset ( $ startPart... | Parse an HTTP request message into an associative array of parts . |
231,528 | public function parseResponse ( $ message ) { if ( ! ( $ parts = $ this -> parseMessage ( $ message ) ) ) { return false ; } list ( $ protocol , $ version ) = explode ( '/' , trim ( $ parts [ 'start_line' ] [ 0 ] ) ) ; return [ 'protocol' => $ protocol , 'protocol_version' => $ version , 'code' => $ parts [ 'start_line... | Parse an HTTP response message into an associative array of parts . |
231,529 | private function parseMessage ( $ message ) { if ( ! $ message ) { return false ; } $ startLine = null ; $ headers = [ ] ; $ body = '' ; $ lines = preg_split ( '/(\\r?\\n)/' , $ message , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 0 , $ totalLines = count ( $ lines ) ; $ i < $ totalLines ; $ i += 2 ) { $ line = $ l... | Parse a message into parts |
231,530 | private function calculate ( ) { $ this -> second = 0 ; $ iters = 0 ; $ maxIters = 100 ; while ( $ iters < $ maxIters && ! $ this -> satisfied ( ) ) { if ( $ this -> params -> minute !== '*' && ( $ this -> minute != $ this -> params -> minute ) ) { if ( $ this -> minute > $ this -> params -> minute ) { $ this -> modify... | Calculates the next run timestamp . |
231,531 | private function satisfied ( ) { return ( $ this -> params -> minute === '*' || $ this -> params -> minute == $ this -> minute ) && ( $ this -> params -> hour === '*' || $ this -> params -> hour == $ this -> hour ) && ( $ this -> params -> day === '*' || $ this -> params -> day == $ this -> day ) && ( $ this -> params ... | Checks if the calculated next run timestamp satisfies the date parameters . |
231,532 | protected function matchFilters ( $ params ) { foreach ( $ this -> filters as $ key => $ expression ) { if ( ! isset ( $ params [ $ key ] ) ) { return false ; } if ( ! preg_match ( $ expression , $ params [ $ key ] ) ) { return false ; } } return true ; } | Validate params against given expressions . |
231,533 | protected function liefhierarchy_parse_options ( array $ options ) { foreach ( $ options as $ key => $ label ) { if ( is_array ( $ label ) ) { $ option = \ ran \ HTMLTag :: i ( $ this -> confs , 'option' , $ key ) -> set ( 'disabled' , '' ) ; $ this -> appendtagbody ( $ option -> render ( ) ) ; $ this -> liefhierarchy_... | Parses hierarchy input array . |
231,534 | function options_table ( array $ table , $ valuekey = null , $ labelkey = null , $ groupkey = null ) { $ optgroups = [ ] ; $ options = [ ] ; if ( $ groupkey === null ) { $ options = static :: associativeFrom ( $ table , $ valuekey , $ labelkey ) ; } else { foreach ( $ table as $ row ) { if ( $ row [ $ groupkey ] !== nu... | Inserts values by interpreting tablular array as is typically the result of a SQL call . If the table is nonstandard you can provide an idkey and titlekey to help the function retrieve the correct values . |
231,535 | protected static function associativeFrom ( array & $ table , $ key_ref = 'id' , $ value_ref = 'title' ) { $ assoc = [ ] ; foreach ( $ table as $ row ) { $ assoc [ $ row [ $ key_ref ] ] = $ row [ $ value_ref ] ; } return $ assoc ; } | Given an array converts it to an associative array based on the key and value reference provided . |
231,536 | public function add ( Route $ route ) : self { if ( $ route -> uri === "" || $ route -> method === 0b0 || $ route -> action === null ) { $ this -> logger -> error ( "Route incomplete. Unable to add" ) ; $ this -> logger -> debug ( "Incomplete Route" , [ $ route ] ) ; throw new Exception \ RouteIncompleteException ( "Re... | Add Route definition |
231,537 | protected function iterateRoutes ( string $ function ) { if ( ( $ route = $ function ( $ this -> routes ) ) !== false ) { $ this -> currentRoute = $ route ; return $ this -> currentRoute ; } return false ; } | Iterate internal Routes array |
231,538 | static function getColumnNames ( ) { $ class = get_called_class ( ) ; if ( ! isset ( self :: $ _columnNames [ $ class ] ) ) { self :: $ _columnNames [ $ class ] = array_keys ( static :: $ _columns ) ; } return self :: $ _columnNames [ $ class ] ; } | Access to array of column names |
231,539 | static function getQuery ( array $ params = array ( ) , Query $ q = null ) { $ model_class = get_called_class ( ) ; $ query_class = class_exists ( $ model_class . 'Query' ) ? $ model_class . 'Query' : 'Dabl\\Query\\Query' ; $ q = $ q ? clone $ q : new $ query_class ; $ tablename = $ q -> getTable ( ) ; if ( ! $ tablena... | Given an array of params construct a query where the keys are used as column names and values as query parameters . Will try to do fully - qualified names . |
231,540 | static function retrieveFromPool ( $ pk_value ) { if ( ! static :: $ _poolEnabled || null === $ pk_value ) { return null ; } $ pk_value = ( string ) $ pk_value ; if ( isset ( static :: $ _instancePool [ $ pk_value ] ) ) { return static :: $ _instancePool [ $ pk_value ] ; } return null ; } | Return the cached instance from the pool . |
231,541 | static function removeFromPool ( $ object_or_pk ) { $ pool_key = $ object_or_pk instanceof Model ? implode ( '-' , $ object_or_pk -> getPrimaryKeyValues ( ) ) : $ object_or_pk ; if ( isset ( static :: $ _instancePool [ $ pool_key ] ) ) { unset ( static :: $ _instancePool [ $ pool_key ] ) ; -- static :: $ _instancePoolC... | Remove the object from the instance pool . |
231,542 | static function doSelectRS ( Query $ q = null ) { $ q = $ q ? clone $ q : static :: getQuery ( ) ; if ( ! $ q -> getTable ( ) ) { $ q -> setTable ( static :: getTableName ( ) ) ; } return $ q -> doSelect ( static :: getConnection ( ) ) ; } | Executes a select query and returns the PDO result |
231,543 | static function doSelectIterator ( Query $ q = null ) { $ q = $ q ? clone $ q : static :: getQuery ( ) ; if ( ! $ q -> getTable ( ) ) { $ q -> setTable ( static :: getTableName ( ) ) ; } return new QueryModelIterator ( $ q , get_called_class ( ) ) ; } | Returns a simple Iterator that wraps PDOStatement for lightweight foreach |
231,544 | function hasPrimaryKeyValues ( ) { $ pks = static :: $ _primaryKeys ; if ( ! $ pks ) return false ; foreach ( $ pks as & $ pk ) if ( $ this -> $ pk === null ) return false ; return true ; } | Returns true if this table has primary keys and if all of the primary values are not null |
231,545 | function getPrimaryKeyValues ( ) { $ arr = array ( ) ; $ pks = static :: $ _primaryKeys ; foreach ( $ pks as & $ pk ) { $ arr [ ] = $ this -> { "get$pk" } ( ) ; } return $ arr ; } | Returns an array of all primary key values . |
231,546 | function castInts ( ) { foreach ( static :: $ _columns as $ column_name => & $ type ) { if ( $ this -> { $ column_name } === null || ! static :: isIntegerType ( $ type ) ) { continue ; } if ( '' === $ this -> { $ column_name } ) { $ this -> { $ column_name } = null ; continue ; } $ this -> { $ column_name } = ( int ) $... | Cast returned values from the database into integers where appropriate . |
231,547 | protected function insert ( ) { $ conn = static :: getConnection ( ) ; $ pk = static :: getPrimaryKey ( ) ; $ fields = array ( ) ; $ values = array ( ) ; $ placeholders = array ( ) ; foreach ( static :: $ _columns as $ column_name => & $ type ) { $ value = $ this -> $ column_name ; if ( $ value === null && ! $ this -> ... | Creates and executes INSERT query string for this object |
231,548 | protected function update ( ) { if ( ! static :: $ _primaryKeys ) { throw new RuntimeException ( 'This table has no primary keys' ) ; } $ column_values = array ( ) ; foreach ( $ this -> getModifiedColumns ( ) as $ column ) { $ column_values [ $ column ] = $ this -> $ column ; } if ( empty ( $ column_values ) ) { return... | Creates and executes UPDATE query string for this object . Returns the number of affected rows . |
231,549 | public function move ( $ directory ) { if ( false === is_string ( $ directory ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ directory ) ) , E_USER_ERROR ) ; } if ( false === is_dir ( $ directory ) ) { return trigger_error ( sprintf (... | Moves the current file to given directory |
231,550 | public function delete ( ) { if ( false !== $ this -> file -> getExists ( ) ) { if ( unlink ( $ this -> file -> getBasepath ( ) ) ) { $ this -> refresh ( ) ; } } return $ this ; } | Deletes current file |
231,551 | public function touch ( $ time = null , $ accesstime = null ) { if ( null !== $ time && false === ( '-' . intval ( $ time ) == '-' . $ time ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ time ) ) , E_USER_ERROR ) ; } if ( null !== $ ... | Sets access and modification time of file . If the file does not exist it will be created |
231,552 | public function copy ( $ directory ) { if ( false === is_string ( $ directory ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ directory ) ) , E_USER_ERROR ) ; } if ( false === is_dir ( $ directory ) ) { return trigger_error ( sprintf (... | Makes a copy of the file to the destination directory |
231,553 | public function rename ( $ name ) { if ( false === is_string ( $ name ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ name ) ) , E_USER_ERROR ) ; } if ( false !== $ this -> file -> getExists ( ) ) { if ( rename ( $ this -> file -> getB... | Attempts to rename oldname to newname . If newname exists it will be overwritten |
231,554 | public function getContent ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; if ( false === $ this -> file -> getReadable ( ) ) { trigger_error ( sprintf ( 'File "%s" is not readable' , $ this -> file -> getBasepath ( ) ) , E_USER_ERROR ) ; } return file_get_contents ( $ this -> file -> g... | Returns the content of current file |
231,555 | public function append ( $ data ) { if ( false === is_string ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } if ( false !== $ this -> file -> getExists ( ) ) { if ( false === is_writable ( $ this ... | Appends data to current file |
231,556 | public function prepend ( $ data ) { if ( false === is_string ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; if ( false ... | Prepends data to current file |
231,557 | public function flush ( ) { if ( false !== $ this -> file -> getExists ( ) ) { if ( false === is_writable ( $ this -> file -> getBasepath ( ) ) ) { return trigger_error ( sprintf ( 'File "%s" passed to %s() is not writable' , $ this -> file -> getBasepath ( ) , __METHOD__ ) , E_USER_ERROR ) ; } $ fh = fopen ( $ this ->... | Empty the current file content |
231,558 | public function chmod ( $ type ) { if ( null !== $ type && false === ( '-' . intval ( $ type ) == '-' . $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ type ) ) , E_USER_ERROR ) ; } if ( false !== $ this -> file -> getExists ( ... | Changes current file mode |
231,559 | public function getAccessTime ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> file -> getAccessTime ( ) ; } } | Returns the access time of current file |
231,560 | public function getGroup ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> file -> getGroup ( ) ; } } | Returns group name of current file |
231,561 | public function getModificationTime ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> file -> getModificationTime ( ) ; } } | Returns the modification time of current file |
231,562 | public function getOwner ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> file -> getOwner ( ) ; } } | Returns the owner of current file |
231,563 | public function isReadable ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> file -> getReadable ( ) ; } return false ; } | Returns if the current file is readable |
231,564 | public function isWritable ( ) { if ( false !== $ this -> file -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> file -> getWritable ( ) ; } return false ; } | Returns if the current file is writable |
231,565 | public function getMime ( ) { if ( null === $ this -> mime ) { $ this -> mime = new Mime ( ) ; } return Mime :: get ( $ this -> file -> getExtension ( ) ) ; } | Returns mime type of current file |
231,566 | public function has ( string $ name ) : bool { if ( isset ( $ this -> all [ $ name ] ) ) return true ; return false ; } | Check if header is present |
231,567 | protected function rebuildConnectionString ( ) { foreach ( $ this -> availableDrivers as $ driverName ) { if ( array_key_exists ( $ driverName , $ this -> connectionStrings ) ) { continue ; } $ ConnStringInterface = __NAMESPACE__ . '\\ConnectionString\\' . ucfirst ( $ driverName ) . 'ConnectionString' ; if ( class_exis... | Rebuild ConnectionString . |
231,568 | public function registerConnectionString ( ConnectionStringInterface $ connString , $ driverName ) { $ this -> connectionStrings [ $ driverName ] = $ connString ; if ( ! in_array ( $ driverName , $ this -> availableDrivers ) ) { $ this -> availableDrivers [ ] = $ driverName ; } $ this -> error -> setMessage ( null ) ; ... | Register new Connection String . |
231,569 | public function getAttr ( $ key = null ) { if ( null !== $ key ) { return isset ( $ this -> attr [ $ attribute ] ) ? $ this -> attr [ $ attribute ] : null ; } return $ this -> attr ; } | Get Current Attribute . |
231,570 | public function setAttrArray ( array $ attributes ) { foreach ( $ attributes as $ attribute => $ value ) { $ this -> setAttr ( $ attribute , $ value ) ; } } | Batch Setup Attribute . |
231,571 | private function __buildConfig ( array $ config ) { foreach ( $ config as $ key => $ conf ) { if ( $ key == 'driver' ) { $ this -> rawConfig [ 'type' ] = strtolower ( $ conf ) ; continue ; } if ( ! array_key_exists ( $ key , $ this -> rawConfig ) ) { $ this -> error -> setMessage ( sprintf ( "invalid config '%s', allow... | Build Self Config . |
231,572 | public function getRawConfig ( ) { $ raw = array ( ) ; foreach ( $ this -> rawConfig as $ key => $ conf ) { $ raw [ $ key ] = call_user_func_array ( array ( $ this , 'get' . ucfirst ( $ key ) ) , array ( ) ) ; } return $ raw ; } | Get Raw Config . |
231,573 | public function getPort ( ) { $ defaultPorts = array ( 'mysql' => '3306' , 'pgsql' => '5432' , 'oci' => '1521' , ) ; if ( ! $ this -> rawConfig [ 'port' ] && isset ( $ defaultPorts [ $ this -> getType ( ) ] ) ) { $ this -> rawConfig [ 'port' ] = $ defaultPorts [ $ this -> getType ( ) ] ; } return intval ( $ this -> raw... | Get Database Port . |
231,574 | public function getDsn ( ) { if ( $ this -> rawConfig [ 'dsn' ] ) { return $ this -> rawConfig [ 'dsn' ] ; } if ( isset ( $ this -> connectionStrings [ $ this -> getType ( ) ] ) ) { return $ this -> connectionStrings [ $ this -> getType ( ) ] -> getDsn ( ) ; } } | Get Database DSN . |
231,575 | public function preventNoLocalDriver ( $ prevented = true ) { if ( $ prevented && ! array_key_exists ( $ this -> getType ( ) , $ this -> connectionStrings ) ) { $ this -> availableDrivers [ ] = $ this -> getType ( ) ; $ this -> rebuildConnectionString ( ) ; } $ this -> preventNoLocalDriver = $ prevented ; } | Prevent error if driver is not available . |
231,576 | protected function bootBindings ( ) { $ this -> app -> singleton ( 'Lia\Addons\JWTAuth\JWTAuth' , function ( $ app ) { return $ app [ 'lia.jwt.auth' ] ; } ) ; $ this -> app -> singleton ( 'Lia\Addons\JWTAuth\Providers\User\UserInterface' , function ( $ app ) { return $ app [ 'lia.jwt.provider.user' ] ; } ) ; $ this -> ... | Bind some Interfaces and implementations . |
231,577 | protected function registerUserProvider ( ) { $ this -> app -> singleton ( 'lia.jwt.provider.user' , function ( $ app ) { $ provider = $ this -> config ( 'providers.user' ) ; $ model = $ app -> make ( $ this -> config ( 'user' ) ) ; return new $ provider ( $ model ) ; } ) ; } | Register the bindings for the User provider . |
231,578 | protected function registerJWTManager ( ) { $ this -> app -> singleton ( 'lia.jwt.manager' , function ( $ app ) { $ instance = new JWTManager ( $ app [ 'lia.jwt.provider.jwt' ] , $ app [ 'lia.jwt.blacklist' ] , $ app [ 'lia.jwt.payload.factory' ] ) ; return $ instance -> setBlacklistEnabled ( ( bool ) $ this -> config ... | Register the bindings for the JWT Manager . |
231,579 | protected function registerPayloadFactory ( ) { $ this -> app -> singleton ( 'lia.jwt.payload.factory' , function ( $ app ) { $ factory = new PayloadFactory ( $ app [ 'lia.jwt.claim.factory' ] , $ app [ 'request' ] , $ app [ 'lia.jwt.validators.payload' ] ) ; return $ factory -> setTTL ( $ this -> config ( 'ttl' ) ) ; ... | Register the bindings for the Payload Factory . |
231,580 | protected function determineClientIpAddress ( $ request ) { $ ipAddress = null ; $ serverParams = $ request -> getServerParams ( ) ; if ( isset ( $ serverParams [ 'REMOTE_ADDR' ] ) && $ this -> isValidIpAddress ( $ serverParams [ 'REMOTE_ADDR' ] ) ) { $ ipAddress = $ serverParams [ 'REMOTE_ADDR' ] ; } $ checkProxyHeade... | Find out the client s IP address from the headers available to us |
231,581 | protected function isValidIpAddress ( $ ip ) { $ flags = FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 ; if ( filter_var ( $ ip , FILTER_VALIDATE_IP , $ flags ) === false ) { return false ; } return true ; } | Check that a given string is a valid IP address |
231,582 | public function offset ( $ date = null ) : string { $ offset = $ this -> offsetInSeconds ( $ date ) ; $ hours = intval ( abs ( $ offset ) / 3600 ) ; $ minutes = ( abs ( $ offset ) - ( $ hours * 3600 ) ) / 60 ; return sprintf ( '%s%02d%02d' , ( $ offset < 0 ? '-' : '+' ) , $ hours , $ minutes ) ; } | returns offset of the time zone |
231,583 | public function offsetInSeconds ( $ date = null ) : int { if ( null === $ date ) { return $ this -> timeZone -> getOffset ( new \ DateTime ( 'now' ) ) ; } return $ this -> timeZone -> getOffset ( Date :: castFrom ( $ date ) -> handle ( ) ) ; } | returns offset to given date in seconds |
231,584 | public function translate ( $ date ) : Date { $ handle = Date :: castFrom ( $ date ) -> handle ( ) ; $ handle -> setTimezone ( $ this -> timeZone ) ; return new Date ( $ handle ) ; } | translates a date from one timezone to a date of this timezone |
231,585 | public function getElementRegister ( ) { if ( $ this -> elementRegister === null ) { $ this -> elementRegister = new ElementRegister ( ) ; $ this -> initializeElementRegister ( $ this -> elementRegister ) ; } return $ this -> elementRegister ; } | Gets the element register . |
231,586 | protected function initializeElementRegister ( ElementRegister $ register ) { $ register -> set ( 'a' , new AnchorElement ( ) ) ; $ register -> set ( 'admonition' , new AdmonitionElement ( ) ) ; $ register -> set ( 'br' , new BreakElement ( ) ) ; $ register -> set ( 'code' , new CodeElement ( ) ) ; $ register -> set ( ... | Initializes athe element register . |
231,587 | public function getLink ( $ page , $ header = null ) { $ id = preg_replace ( '/[^a-z0-9\/]+/i' , '' , $ page ) ; $ link = $ this -> getBaseUrl ( ) . '/' . $ id ; if ( $ header !== null ) { $ link .= '#' . $ this -> createId ( $ header ) ; } else if ( $ id == 'index' ) { $ link = $ this -> getBaseUrl ( ) ; } return $ li... | Gets the link for the given source file . |
231,588 | public function build ( Generator $ generator ) { $ renderer = new DOMRenderer ( $ generator , $ this ) ; $ publisher = new Publisher ( $ generator , $ this ) ; $ pageManager = $ this -> loadPageManager ( $ generator ) ; while ( ! $ pageManager -> getQueue ( ) -> isEmpty ( ) ) { $ page = $ pageManager -> getQueue ( ) -... | Builds the source files . |
231,589 | public function run ( ) { $ method = strtoupper ( $ this -> getRequest ( ) -> getMethod ( ) ) ; $ collections = $ this -> resolveGroupAndWhen ( RouteCollector :: getRoutes ( ) ) ; if ( ! $ this -> hasAnyRouteInRequestMethod ( $ collections , $ method ) ) { $ this -> callRouteNotFoundCommand ( ) ; } $ collections = $ co... | Run the router and check requested uri |
231,590 | protected function dispatchCollection ( $ collection ) { $ group = isset ( $ collection [ 'group' ] ) ? $ collection [ 'group' ] : null ; $ content = $ this -> getActionDispatcher ( ) -> dispatch ( $ collection [ 'action' ] , $ group ) ; if ( is_string ( $ content ) ) { $ this -> sendContentString ( $ content , $ this ... | dispatch matched collection |
231,591 | protected function resolveGroupAndWhen ( $ collections ) { if ( count ( RouteCollector :: getGroups ( ) ) ) { $ collections = $ this -> resolveGroupCollections ( $ collections ) ; } if ( isset ( $ collections [ 'WHEN' ] ) ) { $ collections = $ this -> resolveWhenCollections ( $ collections [ 'WHEN' ] ) ; } if ( count (... | resolve group and when collections |
231,592 | protected function resolveWhenCollections ( array $ collections = [ ] ) { foreach ( $ collections as $ index => $ collection ) { if ( $ this -> getMatcher ( ) -> matchWhen ( $ collection [ 'uri' ] ) ) { RouteCollector :: $ firing [ 'when' ] = $ collection [ 'uri' ] ; app ( ) -> call ( $ collection [ 'action' ] , [ app ... | resolve when collections |
231,593 | private function resolveGroupCollections ( array $ groups = [ ] ) { foreach ( $ groups as $ index => $ group ) { RouteCollector :: $ firing [ 'group' ] = $ group ; app ( ) -> call ( $ group [ 'callback' ] , [ app ( 'route' ) ] ) ; unset ( RouteCollector :: $ firing [ 'group' ] ) ; RouteCollector :: removeGroup ( $ inde... | resolve the when collections |
231,594 | private function sendContentString ( $ content = '' , Request $ request ) { $ response = $ request -> getResponse ( ) ; $ response -> setContent ( $ content ) ; $ response -> send ( ) ; } | send the content |
231,595 | public function detect ( ) { $ detected = true ; if ( empty ( $ this -> ua ) ) { $ detected = false ; } else { if ( ! $ this -> isMSIE ( ) && ! $ this -> isChrome ( ) && ! $ this -> isFirefox ( ) && ! $ this -> isSafari ( ) && ! $ this -> isEdge ( ) && ! $ this -> isOpera ( ) ) { if ( ! $ this -> isOtherMobile ( ) ) { ... | Detects the various items from the user agent and returns what it can in the the array format desired by DeviceFeatureInfo . If nothing can be detected returns null . |
231,596 | private function isSafari ( ) { $ is = false ; if ( preg_match ( "/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//" , $ this -> ua , $ matches ) ) { if ( ! preg_match ( "/(PhantomJS|Silk|rekonq|OPR|Chrome|Android|Edge|bot)/" , $ this -> ua ) ) { $ is = true ; $ major = ( isset ( $ matches [ 2 ] ) ) ? $ matches [ 2 ] : n... | Determines if a browser is Safari by the user agent string . |
231,597 | private function isChrome ( ) { $ is = false ; if ( preg_match ( "/(Chrome|Chromium)\/([0-9\.]+)/" , $ this -> ua , $ matches ) ) { if ( ! preg_match ( "/(MRCHROME|FlyFlow|baidubrowser|bot|Edge)/i" , $ this -> ua ) ) { $ is = true ; $ version = $ matches [ 2 ] ; $ parts = explode ( '.' , $ matches [ 2 ] ) ; $ major = a... | Determines if a browser is chrome by the user agent string . |
231,598 | private function isEdge ( ) { if ( preg_match ( "/Edge (([0-9]+)\.?([0-9]*))/" , $ this -> ua , $ matches ) ) { if ( stripos ( $ this -> ua , 'bot' ) === false ) { $ this -> browser = "edge" ; $ this -> version = $ matches [ 1 ] ; $ this -> major = $ matches [ 2 ] ; $ this -> minor = $ matches [ 3 ] ; } } return false ... | Determines if a browser is Microsoft Edge by the user agent string . |
231,599 | private function isMSIE ( ) { $ is = false ; if ( preg_match ( "/MSIE (([0-9]+)\.?([0-9]*))/" , $ this -> ua , $ matches ) ) { $ is = true ; $ version = $ matches [ 1 ] ; $ major = $ matches [ 2 ] ; $ minor = $ matches [ 3 ] ; } elseif ( preg_match ( "/Trident\/[0-9]\.[0-9]; [^;]*[;\s]*rv:(([0-9]+)\.?([0-9]*))/" , $ th... | Determines if a browser is Internet Explorer by the user agent string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.