idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
53,100
public function instantiate ( $ class ) { $ this -> verifyBootstrap ( ) ; $ instance = $ this -> resolve ( $ class ) ; if ( $ instance === null ) { if ( ! class_exists ( $ class ) ) { throw new ClassNotFoundException ( 'Class not found: ' . $ class ) ; } $ instance = new $ class ( ) ; } return $ instance ; }
Create and return a class instance .
53,101
protected function renderConfigurationExceptions ( Closure $ action ) { try { $ action ( ) ; } catch ( ConfigurationException $ exception ) { if ( ! $ this -> render_configuration_exceptions ) { throw $ exception ; } $ request = Request :: fromGlobals ( ) ; $ handler = $ this -> resolve ( WPEMERGE_EXCEPTIONS_CONFIGURAT...
Catch any configuration exceptions and short - circuit to an error page .
53,102
public function handle ( RequestInterface $ request , $ view = '' ) { if ( is_admin ( ) || ( defined ( 'DOING_AJAX' ) && DOING_AJAX ) ) { throw new ConfigurationException ( 'Attempted to run the default WordPress controller on an ' . 'admin or AJAX page. Did you miss to specify a custom handler for ' . 'a route or acci...
Default WordPress handler .
53,103
protected function input ( $ source , $ key = '' , $ default = null ) { $ source = isset ( $ this -> { $ source } ) && is_array ( $ this -> { $ source } ) ? $ this -> { $ source } : [ ] ; if ( empty ( $ key ) ) { return $ source ; } return Arr :: get ( $ source , $ key , $ default ) ; }
Get all values or a single one from an input type .
53,104
public function execute ( ) { $ arguments = func_get_args ( ) ; if ( $ this -> handler instanceof Closure ) { return call_user_func_array ( $ this -> handler , $ arguments ) ; } $ namespace = $ this -> handler [ 'namespace' ] ; $ class = $ this -> handler [ 'class' ] ; $ method = $ this -> handler [ 'method' ] ; try { ...
Execute the parsed handler with any provided arguments and return the result
53,105
protected function toResponse ( $ exception ) { if ( $ exception instanceof InvalidCsrfTokenException ) { wp_nonce_ays ( '' ) ; } if ( $ exception instanceof NotFoundException ) { return Response :: error ( 404 ) ; } return false ; }
Convert an exception to a ResponseInterface instance if possible .
53,106
protected function toDebugResponse ( RequestInterface $ request , PhpException $ exception ) { if ( $ request -> isAjax ( ) ) { return Response :: json ( [ 'message' => $ exception -> getMessage ( ) , 'exception' => get_class ( $ exception ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) ...
Convert an exception to a debug ResponseInterface instance if possible .
53,107
protected function toPrettyErrorResponse ( $ exception ) { $ method = RunInterface :: EXCEPTION_HANDLER ; ob_start ( ) ; $ this -> whoops -> $ method ( $ exception ) ; $ response = ob_get_clean ( ) ; return Response :: output ( $ response ) -> withStatus ( 500 ) ; }
Convert an exception to a pretty error response .
53,108
public static function getDefaultPath ( ) { if ( DIRECTORY_SEPARATOR !== '\\' ) { return '/etc/hosts' ; } $ path = '%SystemRoot%\\system32\drivers\etc\hosts' ; $ base = getenv ( 'SystemRoot' ) ; if ( $ base === false ) { $ base = 'C:\\Windows' ; } return str_replace ( '%SystemRoot%' , $ base , $ path ) ; }
Returns the default path for the hosts file on this system
53,109
public function getIpsForHost ( $ name ) { $ name = strtolower ( $ name ) ; $ ips = array ( ) ; foreach ( preg_split ( '/\r?\n/' , $ this -> contents ) as $ line ) { $ parts = preg_split ( '/\s+/' , $ line ) ; $ ip = array_shift ( $ parts ) ; if ( $ parts && array_search ( $ name , $ parts ) !== false ) { if ( strpos (...
Returns all IPs for the given hostname
53,110
public function getHostsForIp ( $ ip ) { $ ip = @ inet_pton ( $ ip ) ; if ( $ ip === false ) { return array ( ) ; } $ names = array ( ) ; foreach ( preg_split ( '/\r?\n/' , $ this -> contents ) as $ line ) { $ parts = preg_split ( '/\s+/' , $ line , null , PREG_SPLIT_NO_EMPTY ) ; $ addr = array_shift ( $ parts ) ; if (...
Returns all hostnames for the given IPv4 or IPv6 address
53,111
public function parseMessage ( $ data ) { $ message = new Message ( ) ; if ( $ this -> parse ( $ data , $ message ) !== $ message ) { throw new InvalidArgumentException ( 'Unable to parse binary message' ) ; } return $ message ; }
Parses the given raw binary message into a Message object
53,112
public function parseAnswer ( Message $ message ) { $ record = $ this -> parseRecord ( $ message ) ; if ( $ record === null ) { return null ; } $ message -> answers [ ] = $ record ; if ( $ message -> header -> get ( 'anCount' ) != count ( $ message -> answers ) ) { return $ this -> parseAnswer ( $ message ) ; } return ...
recursively parse all answers from the message data into message answer records
53,113
public function lookup ( Query $ query ) { $ id = $ this -> serializeQueryToIdentity ( $ query ) ; $ expiredAt = $ this -> expiredAt ; return $ this -> cache -> get ( $ id ) -> then ( function ( $ value ) use ( $ query , $ expiredAt ) { if ( $ value === null ) { return Promise \ reject ( ) ; } $ recordBag = unserialize...
Looks up the cache if there s a cached answer for the given query
53,114
public function storeResponseMessage ( $ currentTime , Message $ message ) { foreach ( $ message -> answers as $ record ) { $ this -> storeRecord ( $ currentTime , $ record ) ; } }
Stores all records from this response message in the cache
53,115
public function storeRecord ( $ currentTime , Record $ record ) { $ id = $ this -> serializeRecordToIdentity ( $ record ) ; $ cache = $ this -> cache ; $ this -> cache -> get ( $ id ) -> then ( function ( $ value ) { if ( $ value === null ) { return new RecordBag ( ) ; } return unserialize ( $ value ) ; } , function ( ...
Stores a single record from a response message in the cache
53,116
private function decorateHostsFileExecutor ( ExecutorInterface $ executor ) { try { $ executor = new HostsFileExecutor ( HostsFile :: loadFromPathBlocking ( ) , $ executor ) ; } catch ( \ RuntimeException $ e ) { } if ( DIRECTORY_SEPARATOR === '\\' ) { $ executor = new HostsFileExecutor ( new HostsFile ( "127.0.0.1 loc...
Tries to load the hosts file and decorates the given executor on success
53,117
public static function createRequestForQuery ( Query $ query ) { $ request = new Message ( ) ; $ request -> header -> set ( 'id' , self :: generateId ( ) ) ; $ request -> header -> set ( 'rd' , 1 ) ; $ request -> questions [ ] = ( array ) $ query ; $ request -> prepare ( ) ; return $ request ; }
Creates a new request message for the given query
53,118
public static function createResponseWithAnswersForQuery ( Query $ query , array $ answers ) { $ response = new Message ( ) ; $ response -> header -> set ( 'id' , self :: generateId ( ) ) ; $ response -> header -> set ( 'qr' , 1 ) ; $ response -> header -> set ( 'opcode' , Message :: OPCODE_QUERY ) ; $ response -> head...
Creates a new response message for the given query with the given answer records
53,119
public function perform ( ) { if ( ! $ this -> verifyConfigured ( ) || ! $ this -> verifyEnvironment ( ) ) { return ; } $ found = false ; $ count = $ this -> option ( 'one' ) ? 1 : PHP_INT_MAX ; while ( $ count > 0 && ( $ migration = $ this -> migrator -> run ( ) ) ) { $ found = true ; $ count -- ; $ this -> sprintf ( ...
Execute one or multiple migrations .
53,120
protected function mapDirectories ( array $ directories ) : array { if ( ! isset ( $ directories [ 'root' ] ) ) { throw new BootException ( "Missing required directory `root`." ) ; } if ( ! isset ( $ directories [ 'app' ] ) ) { $ directories [ 'app' ] = $ directories [ 'root' ] . '/app/' ; } return array_merge ( [ 'pub...
Normalizes directory list and adds all required aliases .
53,121
protected function verifyEnvironment ( ) : bool { if ( $ this -> option ( 'force' ) || $ this -> config -> isSafe ( ) ) { return true ; } $ this -> writeln ( "<fg=red>Confirmation is required to run migrations!</fg=red>" ) ; if ( ! $ this -> askConfirmation ( ) ) { $ this -> writeln ( "<comment>Cancelling operation...<...
Check if current environment is safe to run migration .
53,122
public function withOutput ( OutputInterface $ output ) : self { $ listener = clone $ this ; $ listener -> output = $ output ; return $ listener ; }
Configure listener with new output .
53,123
public function enable ( ) : self { if ( ! empty ( $ this -> logs ) ) { $ this -> logs -> addListener ( $ this ) ; } return $ this ; }
Enable logging in console mode .
53,124
public function disable ( ) : self { if ( ! empty ( $ this -> logs ) ) { $ this -> logs -> removeListener ( $ this ) ; } return $ this ; }
Disable displaying logs in console .
53,125
protected function fetchID ( Request $ request ) : ? string { $ cookies = $ request -> getCookieParams ( ) ; if ( empty ( $ cookies [ $ this -> config -> getCookie ( ) ] ) ) { return null ; } return $ cookies [ $ this -> config -> getCookie ( ) ] ; }
Attempt to locate session ID in request .
53,126
protected function clientSignature ( Request $ request ) : string { $ signature = '' ; foreach ( static :: SIGNATURE_HEADERS as $ header ) { $ signature .= $ request -> getHeaderLine ( $ header ) . ';' ; } return hash ( 'sha256' , $ signature ) ; }
Must return string which identifies client on other end . Not for security check but for session fixation .
53,127
private function sessionCookie ( UriInterface $ uri , string $ id = null ) : Cookie { return Cookie :: create ( $ this -> config -> getCookie ( ) , $ id , $ this -> config -> getLifetime ( ) , $ this -> httpConfig -> basePath ( ) , $ this -> httpConfig -> cookieDomain ( $ uri ) , $ this -> config -> isSecure ( ) , true...
Generate session cookie .
53,128
protected function rotateSnapshots ( ) { $ finder = new Finder ( ) ; $ finder -> in ( $ this -> directory ) -> sort ( function ( SplFileInfo $ a , SplFileInfo $ b ) { return $ b -> getMTime ( ) - $ a -> getMTime ( ) ; } ) ; $ count = 0 ; foreach ( $ finder as $ file ) { $ count ++ ; if ( $ count > $ this -> maxFiles ) ...
Remove older snapshots .
53,129
public function boot ( ConfiguratorInterface $ config , HttpBootloader $ http , DirectoriesInterface $ directories ) { $ config -> setDefaults ( 'session' , [ 'lifetime' => 86400 , 'cookie' => 'sid' , 'secure' => false , 'handler' => new Autowire ( FileHandler :: class , [ 'directory' => $ directories -> get ( 'runtime...
Automatically registers session starter middleware and excludes session cookie from cookie protection .
53,130
protected function authorize ( string $ permission , array $ context = [ ] ) : bool { if ( ! $ this -> allows ( $ permission , $ context ) ) { $ name = $ this -> resolvePermission ( $ permission ) ; throw new ControllerException ( "Unauthorized permission '{$name}'" , ControllerException :: FORBIDDEN ) ; } return true ...
Authorize permission or thrown controller exception .
53,131
public function getCachedToken ( ) { if ( $ this -> cachedToken ) { return $ this -> cachedToken ; } $ key = md5 ( $ this -> jwt -> parser ( ) -> parseToken ( ) ) ; $ this -> cachedToken = Cache :: get ( $ key ) ; return $ this -> cachedToken ; }
Return cached token .
53,132
public function setCachedToken ( $ key , $ refreshToken , $ expiresAt = null ) { if ( is_null ( $ expiresAt ) ) { $ expiresAt = ( ( int ) Config :: get ( 'laravel_jwt.cache_ttl' ) / 60 ) ; } Cache :: put ( $ key , $ refreshToken , $ expiresAt ) ; $ this -> cachedToken = $ refreshToken ; return $ this ; }
Set cached token .
53,133
public function refresh ( $ forceForever = false , $ resetClaims = false ) { if ( $ cache = $ this -> getCachedToken ( ) ) { return $ cache ; } $ token = $ this -> jwt -> parser ( ) -> parseToken ( ) ; $ key = md5 ( $ token ) ; $ refreshToken = JWTAuth :: refresh ( $ token , $ forceForever , $ resetClaims ) ; $ this ->...
Refresh current expired token .
53,134
public function verifyAccessToken ( $ accessToken ) { $ jwtPayload = $ this -> decodeAccessToken ( $ accessToken ) ; $ expectedIss = sprintf ( 'https://cognito-idp.%s.amazonaws.com/%s' , $ this -> region , $ this -> userPoolId ) ; if ( $ jwtPayload [ 'iss' ] !== $ expectedIss ) { throw new TokenVerificationException ( ...
Verifies the given access token and returns the username
53,135
public static function classFromRequest ( Request $ request , $ fallbackClass = null ) { foreach ( static :: $ handlers as $ handlerClass ) { if ( $ handlerClass :: canBeUsedForRequest ( $ request ) ) { return $ handlerClass ; break ; } } if ( is_null ( $ fallbackClass ) ) { return static :: $ fallbackHandler ; } retur...
Returns handler class based on the request or the fallback handler .
53,136
public static function canBeUsedForRequest ( Request $ request ) { $ hasChunkParams = $ request -> has ( static :: KEY_CHUNK_NUMBER ) && $ request -> has ( static :: KEY_TOTAL_SIZE ) && $ request -> has ( static :: KEY_CHUNK_SIZE ) && $ request -> has ( static :: KEY_CHUNK_CURRENT_SIZE ) ; return $ hasChunkParams && se...
Checks if the current handler can be used via HandlerFactory .
53,137
protected function getTotalChunksFromRequest ( Request $ request ) { if ( ! $ request -> get ( static :: KEY_CHUNK_SIZE ) ) { return 0 ; } return intval ( ceil ( $ request -> get ( static :: KEY_TOTAL_SIZE ) / $ request -> get ( static :: KEY_CHUNK_SIZE ) ) ) ; }
Returns current chunk from the request .
53,138
public function getChunkDirectory ( $ absolutePath = false ) { $ paths = [ ] ; if ( $ absolutePath ) { $ paths [ ] = $ this -> chunkStorage ( ) -> getDiskPathPrefix ( ) ; } $ paths [ ] = $ this -> chunkStorage ( ) -> directory ( ) ; return implode ( '' , $ paths ) ; }
Returns the folder for the cunks in the storage path on current disk instance .
53,139
protected function handleChunk ( ) { $ this -> createChunksFolderIfNeeded ( ) ; $ file = $ this -> getChunkFilePath ( ) ; $ this -> handleChunkFile ( $ file ) -> tryToBuildFullFileFromChunks ( ) ; }
Appends the new uploaded data to the final file .
53,140
protected function handleChunkFile ( $ file ) { if ( $ this -> handler ( ) -> isFirstChunk ( ) && $ this -> chunkDisk ( ) -> exists ( $ file ) ) { $ this -> chunkDisk ( ) -> delete ( $ file ) ; } ( new FileMerger ( $ this -> getChunkFullFilePath ( ) ) ) -> appendFile ( $ this -> file -> getPathname ( ) ) -> close ( ) ;...
Appends the current uploaded file to chunk file .
53,141
protected function createFullChunkFile ( $ finalPath ) { return new UploadedFile ( $ finalPath , $ this -> file -> getClientOriginalName ( ) , $ this -> file -> getClientMimeType ( ) , filesize ( $ finalPath ) , $ this -> file -> getError ( ) , true ) ; }
Creates the UploadedFile object for given chunk file .
53,142
protected function createChunksFolderIfNeeded ( ) { $ path = $ this -> getChunkDirectory ( true ) ; if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } }
Crates the chunks folder if doesn t exists . Uses recursive create .
53,143
public function receive ( ) { if ( false === is_object ( $ this -> handler ) ) { return false ; } return $ this -> handler -> startSaving ( $ this -> chunkStorage , $ this -> config ) ; }
Tries to handle the upload request . If the file is not uploaded returns false . If the file is present in the request it will create the save object .
53,144
public function files ( $ rejectClosure = null ) { $ filesCollection = new Collection ( $ this -> disk -> files ( $ this -> directory ( ) , false ) ) ; return $ filesCollection -> reject ( function ( $ file ) use ( $ rejectClosure ) { $ shouldReject = ! preg_match ( '/.' . self :: CHUNK_EXTENSION . '$/' , $ file ) ; if...
Returns an array of files in the chunks directory .
53,145
public function oldChunkFiles ( ) { $ files = $ this -> files ( ) ; if ( $ files -> isEmpty ( ) ) { return $ files ; } $ timeToCheck = strtotime ( $ this -> config -> clearTimestampString ( ) ) ; $ collection = new Collection ( ) ; $ files -> each ( function ( $ file ) use ( $ timeToCheck , $ collection ) { $ modified ...
Returns the old chunk files .
53,146
public function handle ( ChunkStorage $ storage ) { $ verbouse = OutputInterface :: VERBOSITY_VERBOSE ; $ oldFiles = $ storage -> oldChunkFiles ( ) ; if ( $ oldFiles -> isEmpty ( ) ) { $ this -> warn ( 'Chunks: no old files' ) ; return ; } $ this -> info ( sprintf ( 'Found %d chunk files' , $ oldFiles -> count ( ) ) , ...
Clears the chunks upload directory .
53,147
public static function canUseSession ( ) { $ session = session ( ) ; $ driver = $ session -> getDefaultDriver ( ) ; $ drivers = $ session -> getDrivers ( ) ; if ( isset ( $ drivers [ $ driver ] ) && true === $ drivers [ $ driver ] -> isStarted ( ) ) { return true ; } return false ; }
Checks the current setup if session driver was booted - if not it will generate random hash .
53,148
public function createChunkFileName ( $ additionalName = null , $ currentChunkIndex = null ) { $ array = [ $ this -> file -> getClientOriginalName ( ) , ] ; $ useSession = $ this -> config -> chunkUseSessionForName ( ) ; $ useBrowser = $ this -> config -> chunkUseBrowserInfoForName ( ) ; if ( $ useSession && false === ...
Builds the chunk file name per session and the original name . You can provide custom additional name at the end of the generated file name . All chunk files has . part extension .
53,149
protected function tryToParseContentRange ( $ contentRange ) { if ( preg_match ( "/bytes ([\d]+)-([\d]+)\/([\d]+)/" , $ contentRange , $ matches ) ) { $ this -> chunkedUpload = true ; $ this -> bytesStart = $ this -> convertToNumericValue ( $ matches [ 1 ] ) ; $ this -> bytesEnd = $ this -> convertToNumericValue ( $ ma...
Tries to parse the content range from the string .
53,150
public function appendFile ( $ sourceFilePath ) { if ( ! $ in = @ fopen ( $ sourceFilePath , 'rb' ) ) { @ fclose ( $ this -> destinationFile ) ; throw new ChunkSaveException ( 'Failed to open input stream' , 101 ) ; } while ( $ buff = fread ( $ in , 4096 ) ) { fwrite ( $ this -> destinationFile , $ buff ) ; } @ fclose ...
Appends given file .
53,151
protected function handleChunkFile ( $ file ) { $ this -> file -> move ( $ this -> getChunkDirectory ( true ) , $ this -> chunkFileName ) ; return $ this ; }
Moves the uploaded chunk file to separate chunk file for merging .
53,152
protected function getSavedChunksFiles ( ) { $ chunkFileName = preg_replace ( "/\.[\d]+\." . ChunkStorage :: CHUNK_EXTENSION . '$/' , '' , $ this -> handler ( ) -> getChunkFileName ( ) ) ; return $ this -> chunkStorage -> files ( function ( $ file ) use ( $ chunkFileName ) { return false === str_contains ( $ file , $ c...
Searches for all chunk files .
53,153
public function boot ( ) { $ config = $ this -> app -> make ( AbstractConfig :: class ) ; $ scheduleConfig = $ config -> scheduleConfig ( ) ; if ( true === Arr :: get ( $ scheduleConfig , 'enabled' , false ) ) { $ this -> app -> booted ( function ( ) use ( $ scheduleConfig ) { $ schedule = $ this -> app -> make ( Sched...
When the service is being booted .
53,154
public function register ( ) { $ this -> commands ( [ ClearChunksCommand :: class , ] ) ; $ this -> registerConfig ( ) ; $ this -> app -> singleton ( AbstractConfig :: class , function ( ) { return new FileConfig ( ) ; } ) ; $ this -> app -> singleton ( ChunkStorage :: class , function ( $ app ) { $ config = $ app -> m...
Register the package requirements .
53,155
protected function registerConfig ( ) { $ configIndex = FileConfig :: FILE_NAME ; $ configFileName = FileConfig :: FILE_NAME . '.php' ; $ configPath = __DIR__ . '/../../config/' . $ configFileName ; $ this -> publishes ( [ $ configPath => config_path ( $ configFileName ) , ] ) ; $ this -> mergeConfigFrom ( $ configPath...
Publishes and mergers the config . Uses the FileConfig . Registers custom handlers .
53,156
protected function registerHandlers ( array $ handlersConfig ) { $ overrideHandlers = Arr :: get ( $ handlersConfig , 'override' , [ ] ) ; if ( count ( $ overrideHandlers ) > 0 ) { HandlerFactory :: setHandlers ( $ overrideHandlers ) ; return $ this ; } foreach ( Arr :: get ( $ handlersConfig , 'custom' , [ ] ) as $ ha...
Registers handlers from config .
53,157
public static function sign ( $ message , PrivateKey $ rsaPrivateKey ) { $ rsa = self :: getRsa ( RSA :: SIGNATURE_PSS ) ; $ return = $ rsa -> loadKey ( $ rsaPrivateKey -> getKey ( ) ) ; if ( $ return === false ) { throw new InvalidKeyException ( 'Signing failed due to invalid key' ) ; } return $ rsa -> sign ( $ messag...
Sign with RSASS - PSS + MGF1 + SHA256
53,158
public static function verify ( $ message , $ signature , PublicKey $ rsaPublicKey ) { $ rsa = self :: getRsa ( RSA :: SIGNATURE_PSS ) ; $ return = $ rsa -> loadKey ( $ rsaPublicKey -> getKey ( ) ) ; if ( $ return === false ) { throw new InvalidKeyException ( 'Verification failed due to invalid key' ) ; } return $ rsa ...
Verify with RSASS - PSS + MGF1 + SHA256
53,159
public function defuseKey ( $ randomBytes ) { $ key = Key :: createNewRandomKey ( ) ; $ func = function ( $ bytes ) { $ this -> key_bytes = $ bytes ; } ; $ helper = $ func -> bindTo ( $ key , $ key ) ; $ helper ( $ randomBytes ) ; return $ key ; }
Use an internally generated key in a Defuse context
53,160
public function escapeFieldPath ( $ fieldPath ) { if ( $ fieldPath instanceof FieldPath ) { $ parts = $ fieldPath -> path ( ) ; $ out = [ ] ; foreach ( $ parts as $ part ) { $ out [ ] = $ this -> escapePathPart ( $ part ) ; } $ fieldPath = implode ( '.' , $ out ) ; } else { if ( ! preg_match ( self :: VALID_FIELD_PATH ...
Escape a field path and return it as a string .
53,161
public function buildDocumentFromPathsAndValues ( array $ paths , array $ values ) { $ this -> validateBatch ( $ paths , FieldPath :: class ) ; $ output = [ ] ; foreach ( $ paths as $ pathIndex => $ path ) { $ keys = $ path -> path ( ) ; $ num = count ( $ keys ) ; $ val = $ values [ $ pathIndex ] ; foreach ( array_reve...
Accepts a list of field paths and a list of values and constructs a nested array of fields and values .
53,162
public function findSentinels ( array $ fields ) { $ timestamps = [ ] ; $ deletes = [ ] ; $ fields = $ this -> removeSentinel ( $ fields , $ timestamps , $ deletes ) ; return [ $ fields , $ timestamps , $ deletes ] ; }
Search an array for sentinel values returning the array of fields with sentinels removed and a list of delete and server timestamp value field paths .
53,163
private function removeSentinel ( array $ fields , array & $ timestamps , array & $ deletes , $ path = '' ) { if ( $ path !== '' ) { $ path .= '.' ; } foreach ( $ fields as $ key => $ value ) { $ currPath = $ path . ( string ) $ this -> escapePathPart ( $ key ) ; if ( is_array ( $ value ) ) { $ fields [ $ key ] = $ thi...
Recurse through fields and find and remove sentinel values .
53,164
private function encodeArrayValue ( array $ value ) { $ out = [ ] ; foreach ( $ value as $ item ) { if ( is_array ( $ item ) && ! $ this -> isAssoc ( $ item ) ) { throw new \ RuntimeException ( 'Nested array values are not permitted.' ) ; } $ out [ ] = $ this -> encodeValue ( $ item ) ; } return [ 'arrayValue' => [ 'va...
Encode a simple array as a Firestore array value .
53,165
public function collection ( string $ path = '' ) : CollectionReference { try { return new CollectionReference ( Uri :: resolve ( $ this -> uri , $ path ) , $ this -> client ) ; } catch ( \ InvalidArgumentException $ e ) { throw new InvalidArgumentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
Returns a collection .
53,166
public function collections ( ) { $ uri = $ this -> uri -> withPath ( $ this -> uri -> getPath ( ) . ':listCollectionIds' ) ; $ value = $ this -> client -> post ( $ uri , null ) ; $ collections = [ ] ; foreach ( $ value [ 'collectionIds' ] as $ id ) { $ collections [ ] = $ this -> collection ( $ id ) ; } return $ colle...
Returns the root collections .
53,167
public function generate ( $ honey_name , $ honey_time ) { $ honey_time_encrypted = $ this -> getEncryptedTime ( ) ; $ html = '<div class="' . $ honey_name . '_wrap" style="display:none;"><input name="' . $ honey_name . '" type="text" value="" id="' . $ honey_name . '"/><input name="' . $ honey_time . '" type="text" va...
Generate a new honeypot and return the form HTML
53,168
public function validateHoneytime ( $ attribute , $ value , $ parameters ) { if ( $ this -> disabled ) { return true ; } $ value = $ this -> decryptTime ( $ value ) ; return ( is_numeric ( $ value ) && time ( ) > ( $ value + $ parameters [ 0 ] ) ) ; }
Validate honey time was within the time limit
53,169
protected function setHashInEnvironmentFile ( $ hash ) { $ envPath = $ this -> laravel -> environmentFilePath ( ) ; $ envContent = $ this -> filesystem -> get ( $ envPath ) ; $ regex = '/UNDER_CONSTRUCTION_HASH=\S+/' ; if ( preg_match ( $ regex , $ envContent ) ) { $ hash = str_replace ( [ '\\' , '$' ] , [ '' , '\$' ] ...
Set the hash in . env file .
53,170
public function validate ( $ code ) : bool { $ codeLength = strlen ( $ code ) ; return ctype_digit ( $ code ) && $ codeLength == $ this -> config [ 'total_digits' ] && strlen ( $ code ) <= 6 ; }
Check if given code is valid .
53,171
public function check ( Request $ request ) { $ request -> validate ( [ 'code' => 'required|numeric' ] ) ; if ( Hash :: check ( $ request -> code , $ this -> getHash ( ) ) ) { session ( [ 'can_visit' => true ] ) ; return response ( [ 'status' => 'success' , ] ) ; } $ this -> incrementLoginAttempts ( $ request ) ; if ( ...
Check if the given code is correct then return the proper response .
53,172
private function showAttempts ( Request $ request ) { if ( $ this -> config [ 'show_attempts_left' ] && $ this -> config [ 'throttle' ] ) { return TransFormer :: transform ( $ this -> retriesLeft ( $ request ) , $ this -> config [ 'attempts_message' ] ) ; } return false ; }
Determine attempts that are left .
53,173
protected function retriesLeft ( Request $ request ) { return $ this -> limiter ( ) -> retriesLeft ( $ this -> throttleKey ( $ request ) , $ this -> maxAttempts ( ) ) ; }
Get the number of attempts left .
53,174
public function updateTimestamps ( $ timestamp = null ) { if ( $ timestamp instanceof \ DateTime ) { $ timestamp = $ timestamp -> getTimestamp ( ) ; } elseif ( is_string ( $ timestamp ) ) { $ timestamp = strtotime ( $ timestamp ) ; } elseif ( ! is_int ( $ timestamp ) ) { $ timestamp = strtotime ( '1984-12-24T00:00:00Z'...
Updates each file s unix timestamps in the PHAR
53,175
public function save ( $ path , $ signatureAlgo ) { $ pos = $ this -> determineSignatureBegin ( ) ; $ algos = array ( \ Phar :: MD5 => 'md5' , \ Phar :: SHA1 => 'sha1' , \ Phar :: SHA256 => 'sha256' , \ Phar :: SHA512 => 'sha512' , ) ; if ( ! isset ( $ algos [ $ signatureAlgo ] ) ) { throw new \ UnexpectedValueExceptio...
Saves the updated phar file optionally with an updated signature .
53,176
private function determineSignatureBegin ( ) { if ( ! preg_match ( '{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}' , $ this -> contents , $ match , PREG_OFFSET_CAPTURE ) ) { throw new \ RuntimeException ( 'Could not detect the stub\'s end in the phar' ) ; } $ pos = $ match [ 0 ] [ 1 ] + strlen ( $ match [ 0 ] [ 0 ] ) ; $ stubE...
Determine the beginning of the signature .
53,177
protected function loadMigrationsFrom ( $ paths ) : void { $ options = \ is_array ( $ paths ) ? $ paths : [ '--path' => $ paths ] ; if ( isset ( $ options [ '--realpath' ] ) && \ is_string ( $ options [ '--realpath' ] ) ) { $ options [ '--path' ] = [ $ options [ '--realpath' ] ] ; } $ options [ '--realpath' ] = true ; ...
Define hooks to migrate the database before and after each test .
53,178
protected function dispatch ( string $ command ) : void { $ console = $ this -> testbench -> artisan ( $ command , $ this -> options ) ; if ( $ console instanceof PendingCommand ) { $ console -> run ( ) ; } }
Dispatch artisan command .
53,179
protected function loadLaravelMigrations ( $ database = [ ] ) : void { $ options = \ is_array ( $ database ) ? $ database : [ '--database' => $ database ] ; $ options [ '--path' ] = 'migrations' ; $ migrator = new MigrateProcessor ( $ this , $ options ) ; $ migrator -> up ( ) ; $ this -> app [ ConsoleKernel :: class ] ...
Migrate Laravel s default migrations .
53,180
final protected function resolveApplicationBindings ( $ app ) : void { foreach ( $ this -> overrideApplicationBindings ( $ app ) as $ original => $ replacement ) { $ app -> bind ( $ original , $ replacement ) ; } }
Resolve application bindings .
53,181
protected function resolveApplicationConfiguration ( $ app ) { $ app -> make ( 'Illuminate\Foundation\Bootstrap\LoadConfiguration' ) -> bootstrap ( $ app ) ; \ tap ( $ this -> getApplicationTimezone ( $ app ) , function ( $ timezone ) { ! \ is_null ( $ timezone ) && \ date_default_timezone_set ( $ timezone ) ; } ) ; $ ...
Resolve application core configuration implementation .
53,182
protected function resolveApplicationBootstrappers ( $ app ) { $ app -> make ( 'Illuminate\Foundation\Bootstrap\HandleExceptions' ) -> bootstrap ( $ app ) ; $ app -> make ( 'Illuminate\Foundation\Bootstrap\RegisterFacades' ) -> bootstrap ( $ app ) ; $ app -> make ( 'Illuminate\Foundation\Bootstrap\SetRequestForConsole'...
Resolve application bootstrapper .
53,183
private static function filterUri ( $ uri ) { if ( $ uri instanceof Psr7UriInterface || $ uri instanceof UriInterface ) { return $ uri ; } throw new TypeError ( sprintf ( 'The uri must be a valid URI object received `%s`' , is_object ( $ uri ) ? get_class ( $ uri ) : gettype ( $ uri ) ) ) ; }
Filter the URI object .
53,184
private static function normalize ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; $ null = $ uri instanceof Psr7UriInterface ? '' : null ; $ path = $ uri -> getPath ( ) ; if ( '/' === ( $ path [ 0 ] ?? '' ) || '' !== $ uri -> getScheme ( ) . $ uri -> getAuthority ( ) ) { $ path = UriResolver :: resolve ( $ uri , $ ur...
Normalize an URI for comparison .
53,185
public static function isAbsolute ( $ uri ) : bool { $ null = $ uri instanceof Psr7UriInterface ? '' : null ; return $ null !== self :: filterUri ( $ uri ) -> getScheme ( ) ; }
Tell whether the URI represents an absolute URI .
53,186
public static function isNetworkPath ( $ uri ) : bool { $ uri = self :: filterUri ( $ uri ) ; $ null = $ uri instanceof Psr7UriInterface ? '' : null ; return $ null === $ uri -> getScheme ( ) && $ null !== $ uri -> getAuthority ( ) ; }
Tell whether the URI represents a network path .
53,187
public static function isRelativePath ( $ uri ) : bool { $ uri = self :: filterUri ( $ uri ) ; $ null = $ uri instanceof Psr7UriInterface ? '' : null ; return $ null === $ uri -> getScheme ( ) && $ null === $ uri -> getAuthority ( ) && '/' !== ( $ uri -> getPath ( ) [ 0 ] ?? '' ) ; }
Tell whether the URI represents a relative path .
53,188
public static function isSameDocument ( $ uri , $ base_uri ) : bool { $ uri = self :: normalize ( $ uri ) ; $ base_uri = self :: normalize ( $ base_uri ) ; return ( string ) $ uri -> withFragment ( $ uri instanceof Psr7UriInterface ? '' : null ) === ( string ) $ base_uri -> withFragment ( $ base_uri instanceof Psr7UriI...
Tell whether both URI refers to the same document .
53,189
private function formatScheme ( ? string $ scheme ) : ? string { if ( '' === $ scheme || null === $ scheme ) { return $ scheme ; } $ formatted_scheme = strtolower ( $ scheme ) ; if ( 1 === preg_match ( self :: REGEXP_SCHEME , $ formatted_scheme ) ) { return $ formatted_scheme ; } throw new SyntaxError ( sprintf ( 'The ...
Format the Scheme and Host component .
53,190
private function formatUserInfo ( ? string $ user , ? string $ password ) : ? string { if ( null === $ user ) { return $ user ; } static $ user_pattern = '/(?:[^%' . self :: REGEXP_CHARS_UNRESERVED . self :: REGEXP_CHARS_SUBDELIM . ']++|%(?![A-Fa-f0-9]{2}))/' ; $ user = preg_replace_callback ( $ user_pattern , [ Uri ::...
Set the UserInfo component .
53,191
private function formatHost ( ? string $ host ) : ? string { if ( null === $ host || '' === $ host ) { return $ host ; } if ( '[' !== $ host [ 0 ] ) { return $ this -> formatRegisteredName ( $ host ) ; } return $ this -> formatIp ( $ host ) ; }
Validate and Format the Host component .
53,192
private function formatRegisteredName ( string $ host ) : string { static $ idn_support = null ; $ idn_support = $ idn_support ?? function_exists ( 'idn_to_ascii' ) && defined ( 'INTL_IDNA_VARIANT_UTS46' ) ; $ formatted_host = rawurldecode ( strtolower ( $ host ) ) ; if ( 1 === preg_match ( self :: REGEXP_HOST_REGNAME ...
Validate and format a registered name .
53,193
private function formatPort ( $ port = null ) : ? int { if ( null === $ port || '' === $ port ) { return null ; } if ( ! is_int ( $ port ) && ! ( is_string ( $ port ) && 1 === preg_match ( '/^\d*$/' , $ port ) ) ) { throw new SyntaxError ( sprintf ( 'The port `%s` is invalid' , $ port ) ) ; } $ port = ( int ) $ port ; ...
Format the Port component .
53,194
public static function createFromString ( $ uri = '' ) : self { $ components = UriString :: parse ( $ uri ) ; return new self ( $ components [ 'scheme' ] , $ components [ 'user' ] , $ components [ 'pass' ] , $ components [ 'host' ] , $ components [ 'port' ] , $ components [ 'path' ] , $ components [ 'query' ] , $ compo...
Create a new instance from a string .
53,195
public static function createFromComponents ( array $ components = [ ] ) : self { $ components += [ 'scheme' => null , 'user' => null , 'pass' => null , 'host' => null , 'port' => null , 'path' => '' , 'query' => null , 'fragment' => null , ] ; return new self ( $ components [ 'scheme' ] , $ components [ 'user' ] , $ c...
Create a new instance from a hash of parse_url parts .
53,196
public static function createFromDataPath ( string $ path , $ context = null ) : self { $ file_args = [ $ path , false ] ; $ mime_args = [ $ path , FILEINFO_MIME ] ; if ( null !== $ context ) { $ file_args [ ] = $ context ; $ mime_args [ ] = $ context ; } $ raw = @ file_get_contents ( ... $ file_args ) ; if ( false ===...
Create a new instance from a data file path .
53,197
public static function createFromUnixPath ( string $ uri = '' ) : self { $ uri = implode ( '/' , array_map ( 'rawurlencode' , explode ( '/' , $ uri ) ) ) ; if ( '/' !== ( $ uri [ 0 ] ?? '' ) ) { return Uri :: createFromComponents ( [ 'path' => $ uri ] ) ; } return Uri :: createFromComponents ( [ 'path' => $ uri , 'sche...
Create a new instance from a Unix path string .
53,198
public static function createFromWindowsPath ( string $ uri = '' ) : self { $ root = '' ; if ( 1 === preg_match ( self :: REGEXP_WINDOW_PATH , $ uri , $ matches ) ) { $ root = substr ( $ matches [ 'root' ] , 0 , - 1 ) . ':' ; $ uri = substr ( $ uri , strlen ( $ root ) ) ; } $ uri = str_replace ( '\\' , '/' , $ uri ) ; ...
Create a new instance from a local Windows path string .
53,199
public static function createFromPsr7 ( Psr7UriInterface $ uri ) : self { $ components = [ 'scheme' => null , 'user' => null , 'pass' => null , 'host' => null , 'port' => $ uri -> getPort ( ) , 'path' => $ uri -> getPath ( ) , 'query' => null , 'fragment' => null , ] ; $ scheme = $ uri -> getScheme ( ) ; if ( '' !== $ ...
Create a new instance from a PSR7 UriInterface object .