idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
56,400 | private function getViewKey ( IView $ view , bool $ checkVars ) : string { $ data = [ 'u' => $ view -> getContents ( ) ] ; if ( $ checkVars ) { $ data [ 'v' ] = $ view -> getVars ( ) ; } return md5 ( http_build_query ( $ data ) ) ; } | Gets key for the cached view |
56,401 | private function validateSaltLength ( string $ salt ) { if ( \ mb_strlen ( $ salt , '8bit' ) !== self :: KEY_SALT_BYTE_LENGTH ) { throw new InvalidArgumentException ( 'Salt must be ' . self :: KEY_SALT_BYTE_LENGTH . ' bytes long' ) ; } } | Verifies the salt length |
56,402 | public function addChild ( Node $ node ) : self { $ node -> setParent ( $ this ) ; $ this -> children [ ] = $ node ; return $ this ; } | Adds a child to this node |
56,403 | protected function getViewCompiler ( IContainer $ container ) : ICompiler { $ registry = new CompilerRegistry ( ) ; $ viewCompiler = new Compiler ( $ registry ) ; $ transpiler = new Transpiler ( new Lexer ( ) , new Parser ( ) , $ this -> viewCache , new XssFilter ( ) ) ; $ container -> bindInstance ( ITranspiler :: cla... | Gets the view compiler To use a different view compiler than the one returned here extend this class and override this method |
56,404 | protected function getViewFactory ( IContainer $ container ) : IViewFactory { $ resolver = new FileViewNameResolver ( ) ; $ resolver -> registerPath ( Config :: get ( 'paths' , 'views.raw' ) ) ; $ resolver -> registerExtension ( 'fortune' ) ; $ resolver -> registerExtension ( 'fortune.php' ) ; $ resolver -> registerExt... | Gets the view view factory To use a different view factory than the one returned here extend this class and override this method |
56,405 | public function getReadConnection ( Server $ preferredServer = null ) : IConnection { if ( $ preferredServer !== null ) { $ this -> addServer ( 'custom' , $ preferredServer ) ; $ this -> setReadConnection ( $ preferredServer ) ; } elseif ( $ this -> readConnection == null ) { $ this -> setReadConnection ( ) ; } return ... | Gets the connection used for read queries |
56,406 | public function getWriteConnection ( Server $ preferredServer = null ) : IConnection { if ( $ preferredServer != null ) { $ this -> addServer ( 'custom' , $ preferredServer ) ; $ this -> setWriteConnection ( $ preferredServer ) ; } elseif ( $ this -> writeConnection == null ) { $ this -> setWriteConnection ( ) ; } retu... | Gets the connection used for write queries |
56,407 | protected function addServer ( string $ type , Server $ server ) { switch ( $ type ) { case 'master' : $ this -> servers [ 'master' ] = [ 'server' => $ server , 'connection' => null ] ; break ; default : $ serverHashId = spl_object_hash ( $ server ) ; if ( ! isset ( $ this -> servers [ $ type ] [ $ serverHashId ] ) ) {... | Adds a server to our list of servers |
56,408 | protected function connectToServer ( Server $ server ) : IConnection { return $ this -> driver -> connect ( $ server , $ this -> connectionOptions , $ this -> driverOptions ) ; } | Creates a database connection |
56,409 | protected function getConnection ( string $ type , Server $ server ) : IConnection { switch ( $ type ) { case 'master' : if ( $ this -> servers [ 'master' ] [ 'server' ] == null ) { throw new RuntimeException ( 'No master specified' ) ; } if ( $ this -> servers [ 'master' ] [ 'connection' ] == null ) { $ this -> server... | Gets a connection to the input server |
56,410 | public function fromRedisTimestamp ( $ timestamp ) : DateTime { $ date = DateTime :: createFromFormat ( 'U' , $ timestamp ) ; $ date -> setTimezone ( new DateTimeZone ( date_default_timezone_get ( ) ) ) ; return $ date ; } | Converts a Redis Unix timestamp to a PHP timestamp |
56,411 | private function createHmac ( string $ iv , string $ keySalt , string $ cipher , string $ value , string $ authenticationKey ) : string { return \ hash_hmac ( self :: $ hmacAlgorithm , self :: $ version . $ cipher . $ iv . $ keySalt . $ value , $ authenticationKey ) ; } | Creates an HMAC |
56,412 | private function deriveKeys ( string $ cipher , string $ keySalt ) : DerivedKeys { $ keyByteLength = $ this -> getKeyByteLengthForCipher ( $ cipher ) ; if ( $ this -> secret -> getType ( ) === SecretTypes :: KEY ) { return $ this -> keyDeriver -> deriveKeysFromKey ( $ this -> secret -> getValue ( ) , $ keySalt , $ keyB... | Derives keys that are suitable for encryption and decryption |
56,413 | private function getPieces ( string $ data ) : array { $ pieces = \ json_decode ( \ base64_decode ( $ data ) , true ) ; if ( $ pieces === false || ! isset ( $ pieces [ 'version' ] , $ pieces [ 'hmac' ] , $ pieces [ 'value' ] , $ pieces [ 'iv' ] , $ pieces [ 'keySalt' ] , $ pieces [ 'cipher' ] ) ) { throw new Encryption... | Converts the input data to an array of pieces |
56,414 | private function validateSecret ( string $ cipher ) { if ( $ this -> secret -> getType ( ) === SecretTypes :: KEY ) { if ( \ mb_strlen ( $ this -> secret -> getValue ( ) , '8bit' ) < $ this -> getKeyByteLengthForCipher ( $ cipher ) ) { throw new EncryptionException ( "Key must be at least {$this->getKeyByteLengthForCip... | Validates the secret |
56,415 | public function copyDirectory ( string $ source , string $ target , int $ flags = null ) : bool { if ( ! $ this -> exists ( $ source ) ) { return false ; } if ( ! $ this -> isDirectory ( $ target ) && ! $ this -> makeDirectory ( $ target , 0777 , true ) ) { return false ; } if ( $ flags === null ) { $ flags = Filesyste... | Copies directories to a new path |
56,416 | public function getBasename ( string $ path ) : string { if ( ! $ this -> exists ( $ path ) ) { throw new FileSystemException ( "Path $path not found" ) ; } return pathinfo ( $ path , PATHINFO_BASENAME ) ; } | Gets the basename of a path |
56,417 | public function getDirectories ( string $ path , bool $ isRecursive = false ) : array { if ( ! $ this -> isDirectory ( $ path ) ) { return [ ] ; } $ directories = [ ] ; $ iter = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterato... | Gets all of the directories at the input path |
56,418 | public function getDirectoryName ( string $ path ) : string { if ( ! $ this -> exists ( $ path ) ) { throw new FileSystemException ( "File at path $path not found" ) ; } return pathinfo ( $ path , PATHINFO_DIRNAME ) ; } | Gets the directory name of a file |
56,419 | public function getExtension ( string $ path ) : string { if ( ! $ this -> exists ( $ path ) ) { throw new FileSystemException ( "File at path $path not found" ) ; } return pathinfo ( $ path , PATHINFO_EXTENSION ) ; } | Gets the extension of a file |
56,420 | public function getFileName ( string $ path ) : string { if ( ! $ this -> exists ( $ path ) ) { throw new FileSystemException ( "File at path $path not found" ) ; } return pathinfo ( $ path , PATHINFO_FILENAME ) ; } | Gets the file name of a file |
56,421 | public function getFiles ( string $ path , bool $ isRecursive = false ) : array { if ( ! $ this -> isDirectory ( $ path ) ) { return [ ] ; } $ files = [ ] ; $ iter = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FI... | Gets all of the files at the input path |
56,422 | public function getLastModified ( string $ path ) : DateTime { if ( ! $ this -> exists ( $ path ) ) { throw new FileSystemException ( "File at path $path not found" ) ; } $ modifiedTimestamp = filemtime ( $ path ) ; if ( $ modifiedTimestamp === false ) { throw new FileSystemException ( "Failed to get last modified time... | Gets the last modified time |
56,423 | public function glob ( string $ pattern , int $ flags = 0 ) : array { $ files = glob ( $ pattern , $ flags ) ; if ( $ files === false ) { throw new FileSystemException ( "Glob failed for pattern \"$pattern\" with flags $flags" ) ; } return $ files ; } | Finds files that match a pattern |
56,424 | public function makeDirectory ( string $ path , int $ mode = 0777 , bool $ isRecursive = false ) : bool { $ result = mkdir ( $ path , $ mode , $ isRecursive ) ; chmod ( $ path , $ mode ) ; return $ result ; } | Makes a directory at the input path |
56,425 | public function read ( string $ path ) : string { if ( ! $ this -> isFile ( $ path ) ) { throw new FileSystemException ( "File at path $path not found" ) ; } return file_get_contents ( $ path ) ; } | Reads the contents of a file |
56,426 | public function run ( string $ input , array $ options = [ ] ) : string { $ filteredInput = $ input ; if ( isset ( $ options [ 'forUrl' ] ) && $ options [ 'forUrl' ] ) { $ filteredInput = str_replace ( "'" , '%27' , $ input ) ; } $ filteredInput = filter_var ( $ filteredInput , FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ; re... | Filters the input parameter for XSS attacks |
56,427 | public function format ( array $ rows , array $ headers = [ ] ) : string { if ( count ( $ rows ) === 0 ) { return '' ; } foreach ( $ rows as & $ row ) { $ row = ( array ) $ row ; } unset ( $ row ) ; $ headersAndRows = count ( $ headers ) === 0 ? $ rows : array_merge ( [ $ headers ] , $ rows ) ; $ headersAndRows = count... | Formats the table into a string |
56,428 | public function createFromName ( string $ name , ... $ args ) : string { $ route = $ this -> routeCollection -> getNamedRoute ( $ name ) ; if ( $ route === null ) { return '' ; } return $ this -> generateHost ( $ route , $ args ) . $ this -> generatePath ( $ route , $ args ) ; } | Creates a URL for the named route This function accepts variable - length arguments after the name |
56,429 | public function createRegexFromName ( string $ name ) : string { $ route = $ this -> routeCollection -> getNamedRoute ( $ name ) ; if ( $ route === null ) { return '#^.*$#' ; } $ strippedPathRegex = substr ( $ route -> getPathRegex ( ) , 2 , - 2 ) ; if ( empty ( $ route -> getRawHost ( ) ) ) { return "#^$strippedPathRe... | Creates a URL regex for the named route |
56,430 | private function generateHost ( ParsedRoute $ route , & $ values ) : string { $ host = '' ; if ( ! empty ( $ route -> getRawHost ( ) ) ) { $ host = $ this -> generateUrlPart ( $ route -> getRawHost ( ) , $ route -> getHostRegex ( ) , $ route -> getName ( ) , $ values ) ; $ host = 'http' . ( $ route -> isSecure ( ) ? 's... | Generates the host portion of a URL for a route |
56,431 | private function generatePath ( ParsedRoute $ route , & $ values ) : string { return $ this -> generateUrlPart ( $ route -> getRawPath ( ) , $ route -> getPathRegex ( ) , $ route -> getName ( ) , $ values ) ; } | Generates the path portion of a URL for a route |
56,432 | private function generateUrlPart ( string $ rawPart , string $ regex , string $ routeName , & $ values ) : string { $ generatedPart = $ rawPart ; $ count = 1000 ; while ( $ count > 0 && count ( $ values ) > 0 ) { $ generatedPart = preg_replace ( self :: $ variableMatchingRegex , $ values [ 0 ] , $ generatedPart , 1 , $... | Generates a part of a URL for a route |
56,433 | protected function bindCommands ( CommandCollection $ commands , IContainer $ container ) { foreach ( self :: $ commandClasses as $ commandClass ) { $ commands -> add ( $ container -> resolve ( $ commandClass ) ) ; } $ commands -> add ( new RunAppLocallyCommand ( Config :: get ( 'paths' , 'root' ) . '/localhost_router.... | Binds commands to the collection |
56,434 | protected function getSubjectFromJwt ( SignedJwt $ jwt , ICredential $ credential ) : ISubject { $ roles = $ jwt -> getPayload ( ) -> get ( 'roles' ) ? : [ ] ; return new Subject ( [ new Principal ( PrincipalTypes :: PRIMARY , $ jwt -> getPayload ( ) -> getSubject ( ) , $ roles ) ] , [ $ credential ] ) ; } | Gets a subject from a JWT |
56,435 | public function callMethod ( string $ methodName , array $ parameters ) : Response { $ this -> setUpView ( ) ; $ response = $ this -> $ methodName ( ... $ parameters ) ; if ( $ response === null || is_string ( $ response ) ) { $ response = new Response ( $ response === null ? '' : $ response ) ; if ( $ this -> viewComp... | Actually calls the method in the controller Rather than calling the method directly from the route dispatcher call this method |
56,436 | protected function parseData ( string $ key ) : array { if ( file_exists ( $ this -> getPath ( $ key ) ) ) { $ rawData = json_decode ( file_get_contents ( $ this -> getPath ( $ key ) ) , true ) ; $ parsedData = [ 'd' => unserialize ( $ rawData [ 'd' ] ) , 't' => $ rawData [ 't' ] ] ; } else { $ parsedData = [ 'd' => nu... | Runs garbage collection on a key if necessary |
56,437 | protected function serialize ( $ data , int $ lifetime ) : string { return json_encode ( [ 'd' => serialize ( $ data ) , 't' => time ( ) + $ lifetime ] ) ; } | Serializes the data with lifetime information |
56,438 | protected function unserialize ( string $ data ) { $ unserializedData = json_decode ( $ data , true ) ; $ unserializedData [ 'd' ] = unserialize ( $ unserializedData [ 'd' ] ) ; return $ unserializedData ; } | Unserializes the data from storage |
56,439 | public function between ( string $ column , $ min , $ max , $ dataType = PDO :: PARAM_STR ) : BetweenCondition { return new BetweenCondition ( $ column , $ min , $ max , $ dataType ) ; } | Creates a new BETWEEN condition |
56,440 | public function notBetween ( string $ column , $ min , $ max , $ dataType = PDO :: PARAM_STR ) : NotBetweenCondition { return new NotBetweenCondition ( $ column , $ min , $ max , $ dataType ) ; } | Creates a new NOT BETWEEN condition |
56,441 | protected function getSignedJwt ( ISubject $ subject ) : SignedJwt { $ jwtPayload = new JwtPayload ( ) ; $ jwtPayload -> setIssuer ( $ this -> issuer ) ; $ jwtPayload -> setAudience ( $ this -> audience ) ; $ jwtPayload -> setSubject ( $ subject -> getPrimaryPrincipal ( ) -> getId ( ) ) ; $ jwtPayload -> setValidFrom (... | Gets the signed JWT for a subject |
56,442 | public function findAll ( $ paths ) : array { if ( is_string ( $ paths ) ) { $ paths = [ $ paths ] ; } if ( ! is_array ( $ paths ) ) { throw new InvalidArgumentException ( 'Paths must be a string or array' ) ; } $ allClassNames = [ ] ; foreach ( $ paths as $ path ) { if ( ! is_dir ( $ path ) ) { throw new InvalidArgume... | Recursively finds all migration classes in the order they re to be run |
56,443 | private function getClassNamesFromTokens ( array $ tokens ) : array { for ( $ i = 0 ; $ i < count ( $ tokens ) ; $ i ++ ) { if ( is_string ( $ tokens [ $ i ] ) ) { continue ; } $ className = '' ; switch ( $ tokens [ $ i ] [ 0 ] ) { case T_NAMESPACE : $ namespace = '' ; while ( isset ( $ tokens [ ++ $ i ] [ 1 ] ) ) { if... | Gets the class names from a list of tokens This will work even if multiple classes are defined in each file |
56,444 | public static function createFromGlobals ( array $ query = null , array $ post = null , array $ cookies = null , array $ server = null , array $ files = null , array $ env = null , string $ rawBody = null ) : Request { $ query = $ query ?? $ _GET ; $ post = $ post ?? $ _POST ; $ cookies = $ cookies ?? $ _COOKIE ; $ ser... | Creates an instance of this class using the PHP globals |
56,445 | public function getFullUrl ( ) : string { $ isSecure = $ this -> isSecure ( ) ; $ rawProtocol = strtolower ( $ this -> server -> get ( 'SERVER_PROTOCOL' ) ) ; $ parsedProtocol = substr ( $ rawProtocol , 0 , strpos ( $ rawProtocol , '/' ) ) . ( $ isSecure ? 's' : '' ) ; $ port = $ this -> getPort ( ) ; $ host = $ this -... | Gets the full URL for the current request |
56,446 | public function getHost ( ) : string { $ host = null ; if ( $ this -> isUsingTrustedProxy ( ) && $ this -> headers -> has ( self :: $ trustedHeaderNames [ RequestHeaders :: CLIENT_HOST ] ) ) { $ hosts = explode ( ',' , $ this -> headers -> get ( self :: $ trustedHeaderNames [ RequestHeaders :: CLIENT_HOST ] ) ) ; $ hos... | Gets the host name |
56,447 | public function getInput ( string $ name , $ default = null ) { if ( $ this -> isJson ( ) ) { $ json = $ this -> getJsonBody ( ) ; if ( array_key_exists ( $ name , $ json ) ) { return $ json [ $ name ] ; } else { return $ default ; } } else { $ value = null ; switch ( $ this -> method ) { case RequestMethods :: GET : r... | Gets the input from either GET or POST data |
56,448 | public function getJsonBody ( ) : array { $ json = json_decode ( $ this -> getRawBody ( ) , true ) ; if ( $ json === null ) { throw new RuntimeException ( 'Body could not be decoded as JSON' ) ; } return $ json ; } | Gets the raw body as a JSON array |
56,449 | public function getPort ( ) : int { if ( $ this -> isUsingTrustedProxy ( ) ) { if ( $ this -> server -> has ( self :: $ trustedHeaderNames [ RequestHeaders :: CLIENT_PORT ] ) ) { return ( int ) $ this -> server -> get ( self :: $ trustedHeaderNames [ RequestHeaders :: CLIENT_PORT ] ) ; } elseif ( $ this -> server -> ge... | Gets the port number |
56,450 | public function getPreviousUrl ( bool $ fallBackToReferer = true ) : string { if ( ! empty ( $ this -> previousUrl ) ) { return $ this -> previousUrl ; } if ( $ fallBackToReferer ) { return $ this -> headers -> get ( 'REFERER' , '' ) ; } return '' ; } | The previous URL if one was set otherwise the referrer header |
56,451 | public function isPath ( string $ path , bool $ isRegex = false ) : bool { if ( $ isRegex ) { return preg_match ( '#^' . $ path . '$#' , $ this -> path ) === 1 ; } else { return $ this -> path == $ path ; } } | Gets whether or not the current path matches the input path or regular expression |
56,452 | public function isSecure ( ) : bool { if ( $ this -> isUsingTrustedProxy ( ) && $ this -> server -> has ( self :: $ trustedHeaderNames [ RequestHeaders :: CLIENT_PROTO ] ) ) { $ protoString = $ this -> server -> get ( self :: $ trustedHeaderNames [ RequestHeaders :: CLIENT_PROTO ] ) ; $ protoArray = explode ( ',' , $ p... | Gets whether or not the request was made through HTTPS |
56,453 | public function isUrl ( string $ url , bool $ isRegex = false ) : bool { if ( $ isRegex ) { return preg_match ( '#^' . $ url . '$#' , $ this -> getFullUrl ( ) ) === 1 ; } else { return $ this -> getFullUrl ( ) == $ url ; } } | Gets whether or not the current URL matches the input URL or regular expression |
56,454 | public function setMethod ( string $ method = null ) { if ( $ method === null ) { $ method = $ this -> server -> get ( 'REQUEST_METHOD' , RequestMethods :: GET ) ; if ( $ method == RequestMethods :: POST ) { if ( ( $ overrideMethod = $ this -> server -> get ( 'X-HTTP-METHOD-OVERRIDE' ) ) !== null ) { $ method = $ overr... | Sets the method If no input is specified then it is automatically set using headers |
56,455 | public function setPath ( string $ path = null ) { if ( $ path === null ) { $ uri = $ this -> server -> get ( 'REQUEST_URI' ) ; if ( empty ( $ uri ) ) { $ this -> path = '/' ; } else { $ uriParts = explode ( '?' , $ uri ) ; $ this -> path = $ uriParts [ 0 ] ; } } else { $ this -> path = $ path ; } } | Sets the path of this request which does not include the query string If no input is specified then it is automatically set using headers |
56,456 | private function setClientIPAddresses ( ) { if ( $ this -> isUsingTrustedProxy ( ) ) { $ this -> clientIPAddresses = [ $ this -> server -> get ( 'REMOTE_ADDR' ) ] ; } else { $ ipAddresses = [ ] ; if ( $ this -> headers -> has ( self :: $ trustedHeaderNames [ RequestHeaders :: FORWARDED ] ) ) { $ header = $ this -> head... | Sets the client IP addresses |
56,457 | public function addMiddleware ( $ middleware , bool $ prepend = false ) { if ( ! is_array ( $ middleware ) ) { $ middleware = [ $ middleware ] ; } if ( $ prepend ) { $ this -> middleware = array_merge ( $ middleware , $ this -> middleware ) ; } else { $ this -> middleware = array_merge ( $ this -> middleware , $ middle... | Adds middleware to this route |
56,458 | public function setVarRegexes ( array $ regexes ) { foreach ( $ regexes as $ varName => $ regex ) { $ this -> setVarRegex ( $ varName , $ regex ) ; } } | Sets regexes variables must satisfy |
56,459 | protected function setControllerVars ( $ controller ) { $ this -> controller = $ controller ; if ( is_callable ( $ controller ) ) { $ this -> setControllerCallable ( $ controller ) ; } else { $ this -> usesCallable = false ; $ atCharPos = strpos ( $ controller , '@' ) ; if ( $ atCharPos === false || $ atCharPos === 0 |... | Sets the controller name and method from the raw string |
56,460 | protected function transpileDirectiveNode ( Node $ node ) : string { $ children = $ node -> getChildren ( ) ; if ( count ( $ children ) === 0 ) { return '' ; } $ directiveName = $ children [ 0 ] -> getValue ( ) ; $ expression = count ( $ children ) === 2 ? $ children [ 1 ] -> getValue ( ) : '' ; if ( ! isset ( $ this -... | Transpiles a directive node |
56,461 | protected function transpileNodes ( AbstractSyntaxTree $ ast ) : string { $ transpiledView = '' ; $ rootNode = $ ast -> getRootNode ( ) ; $ previousNodeWasExpression = false ; foreach ( $ rootNode -> getChildren ( ) as $ childNode ) { switch ( get_class ( $ childNode ) ) { case DirectiveNode :: class : $ transpiledView... | Transpiles all nodes in an abstract syntax tree |
56,462 | protected function transpileSanitizedTagNode ( Node $ node ) : string { $ code = '' ; foreach ( $ node -> getChildren ( ) as $ childNode ) { $ code .= '<?php echo $__opulenceFortuneTranspiler->sanitize(' . $ childNode -> getValue ( ) . '); ?>' ; } return $ code ; } | Transpiles a sanitized tag node |
56,463 | protected function prepareForUnserialization ( string $ data = null ) : string { if ( $ data === null ) { return '' ; } if ( $ this -> usesEncryption ) { if ( $ this -> encrypter === null ) { throw new LogicException ( 'Encrypter not set on session handler' ) ; } try { return $ this -> encrypter -> decrypt ( $ data ) ;... | Prepares data that is about to be unserialized |
56,464 | protected function prepareForWrite ( string $ data ) : string { if ( $ this -> usesEncryption ) { if ( $ this -> encrypter === null ) { throw new LogicException ( 'Encrypter not set in session handler' ) ; } try { return $ this -> encrypter -> encrypt ( $ data ) ; } catch ( SessionEncryptionException $ ex ) { return ''... | Prepares data to be written to storage |
56,465 | public function getDefaultValue ( string $ variableName ) { if ( isset ( $ this -> defaultValues [ $ variableName ] ) ) { return $ this -> defaultValues [ $ variableName ] ; } return null ; } | Gets the default value for a variable |
56,466 | protected function postCommit ( ) { foreach ( $ this -> dataMappers as $ className => $ dataMapper ) { if ( $ dataMapper instanceof ICachedSqlDataMapper ) { $ dataMapper -> commit ( ) ; } } } | Performs any actions after the commit |
56,467 | protected function getRulesFactory ( IContainer $ container ) : RulesFactory { return new RulesFactory ( $ this -> ruleExtensionRegistry , $ this -> errorTemplateRegistry , $ this -> errorTemplateCompiler ) ; } | Gets the rules factory |
56,468 | protected function getEncrypter ( ) : IEncrypter { $ encodedEncryptionKey = getenv ( 'ENCRYPTION_KEY' ) ; if ( $ encodedEncryptionKey === null ) { throw new RuntimeException ( '"ENCRYPTION_KEY" value not set in environment. Check that you have it set in an environment config file such as ".env.app.php". Note: ".env.... | Gets the encrypter to use |
56,469 | protected function nameHasExtension ( string $ name , array $ sortedExtensions ) : bool { foreach ( $ sortedExtensions as $ extension ) { $ lengthDifference = strlen ( $ name ) - strlen ( $ extension ) ; if ( $ lengthDifference > 0 && strpos ( $ name , $ extension , $ lengthDifference ) !== false ) { return true ; } } ... | Gets whether or not a name has an extension |
56,470 | protected function sortByPriority ( array $ list ) : array { $ nonPriorityItems = [ ] ; $ priorityItems = [ ] ; foreach ( $ list as $ key => $ priority ) { if ( $ priority == - 1 ) { $ nonPriorityItems [ ] = $ key ; } else { $ priorityItems [ $ key ] = $ priority ; } } asort ( $ priorityItems ) ; return array_merge ( a... | Sorts a list whose values are priorities |
56,471 | private function getHashAlgorithm ( string $ algorithm ) : string { switch ( $ algorithm ) { case Algorithms :: SHA256 : return 'sha256' ; case Algorithms :: SHA384 : return 'sha384' ; case Algorithms :: SHA512 : return 'sha512' ; default : throw new InvalidArgumentException ( "Algorithm \"$algorithm\" is not a hash al... | Gets the hash algorithm for an algorithm |
56,472 | protected function parseLongOption ( string $ token , array & $ remainingTokens ) : array { if ( mb_strpos ( $ token , '--' ) !== 0 ) { throw new RuntimeException ( "Invalid long option \"$token\"" ) ; } $ option = mb_substr ( $ token , 2 ) ; if ( mb_strpos ( $ option , '=' ) === false ) { $ nextToken = array_shift ( $... | Parses a long option token and returns an array of data |
56,473 | protected function parseShortOption ( string $ token ) : array { if ( mb_substr ( $ token , 0 , 1 ) !== '-' ) { throw new RuntimeException ( "Invalid short option \"$token\"" ) ; } $ token = mb_substr ( $ token , 1 ) ; $ options = [ ] ; $ tokens = preg_split ( '//u' , $ token , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $... | Parses a short option token and returns an array of data |
56,474 | protected function parseTokens ( array $ tokens ) : Request { $ request = new Request ( ) ; $ hasParsedCommandName = false ; while ( $ token = array_shift ( $ tokens ) ) { if ( mb_strpos ( $ token , '--' ) === 0 ) { $ option = $ this -> parseLongOption ( $ token , $ tokens ) ; $ request -> addOptionValue ( $ option [ 0... | Parses a list of tokens into a request |
56,475 | protected function trimQuotes ( string $ token ) : string { if ( ( $ firstValueChar = mb_substr ( $ token , 0 , 1 ) ) === mb_substr ( $ token , - 1 ) ) { if ( $ firstValueChar === "'" ) { $ token = trim ( $ token , "'" ) ; } elseif ( $ firstValueChar === '"' ) { $ token = trim ( $ token , '"' ) ; } } return $ token ; } | Trims the outer - most quotes from a token |
56,476 | protected function compileArguments ( ICommand $ command , IRequest $ request ) { $ argumentValues = $ request -> getArgumentValues ( ) ; $ commandArguments = $ command -> getArguments ( ) ; if ( $ this -> hasTooManyArguments ( $ argumentValues , $ commandArguments ) ) { throw new RuntimeException ( 'Too many arguments... | Compiles arguments in a command |
56,477 | protected function compileOptions ( ICommand $ command , IRequest $ request ) { foreach ( $ command -> getOptions ( ) as $ option ) { $ shortNameIsSet = $ option -> getShortName ( ) === null ? false : $ request -> optionIsSet ( $ option -> getShortName ( ) ) ; $ longNameIsSet = $ request -> optionIsSet ( $ option -> ge... | Compiles options in a command |
56,478 | private function hasTooManyArguments ( array $ argumentValues , array $ commandArguments ) : bool { if ( count ( $ argumentValues ) > count ( $ commandArguments ) ) { if ( count ( $ commandArguments ) === 0 || ! end ( $ commandArguments ) -> isArray ( ) ) { return true ; } } return false ; } | Gets whether or not there are too many argument values |
56,479 | public static function createFromRawConfig ( string $ rootPath , string $ psr4RootPath ) : Composer { $ composerConfigPath = "$rootPath/composer.json" ; if ( file_exists ( $ composerConfigPath ) ) { return new Composer ( json_decode ( file_get_contents ( $ composerConfigPath ) , true ) , $ rootPath , $ psr4RootPath ) ;... | Creates an instance of this class from a raw Composer config file |
56,480 | public function get ( string $ property ) { $ properties = explode ( '.' , $ property ) ; $ value = $ this -> rawConfig ; foreach ( $ properties as $ property ) { if ( ! array_key_exists ( $ property , $ value ) ) { return null ; } $ value = $ value [ $ property ] ; } return $ value ; } | Gets the value of a property |
56,481 | public function getClassPath ( string $ fullyQualifiedClassName ) : string { $ parts = explode ( '\\' , $ fullyQualifiedClassName ) ; if ( file_exists ( realpath ( $ this -> psr4RootPath . '/' . $ parts [ 0 ] ) ) ) { $ path = array_slice ( $ parts , 0 , - 1 ) ; } else { $ path = array_slice ( $ parts , 1 , - 1 ) ; } $ ... | Gets the path from a fully - qualified class name |
56,482 | public function getFullyQualifiedClassName ( string $ className , string $ defaultNamespace ) : string { $ rootNamespace = $ this -> getRootNamespace ( ) ; if ( mb_strpos ( $ className , $ rootNamespace ) === 0 ) { return $ className ; } return trim ( $ defaultNamespace , '\\' ) . '\\' . $ className ; } | Gets the fully - qualified class name |
56,483 | public function getRootNamespace ( ) { if ( ( $ psr4 = $ this -> get ( 'autoload.psr-4' ) ) === null ) { return null ; } foreach ( $ psr4 as $ namespace => $ namespacePaths ) { foreach ( ( array ) $ namespacePaths as $ namespacePath ) { if ( mb_strpos ( realpath ( $ this -> rootPath . '/' . $ namespacePath ) , realpath... | Gets the root namespace for the application |
56,484 | public function addTextStyle ( string $ style ) { if ( ! isset ( self :: $ supportedTextStyles [ $ style ] ) ) { throw new InvalidArgumentException ( "Invalid text style \"$style\"" ) ; } if ( ! in_array ( $ style , $ this -> textStyles ) ) { $ this -> textStyles [ ] = $ style ; } } | Adds the text to have a certain style |
56,485 | public function format ( string $ text ) : string { if ( $ text === '' ) { return $ text ; } $ startCodes = [ ] ; $ endCodes = [ ] ; if ( $ this -> foregroundColor !== null ) { $ startCodes [ ] = self :: $ supportedForegroundColors [ $ this -> foregroundColor ] [ 0 ] ; $ endCodes [ ] = self :: $ supportedForegroundColo... | Formats text with the the currently - set styles |
56,486 | public function removeTextStyle ( string $ style ) { if ( ! isset ( self :: $ supportedTextStyles [ $ style ] ) ) { throw new InvalidArgumentException ( "Invalid text style \"$style\"" ) ; } if ( ( $ index = array_search ( $ style , $ this -> textStyles ) ) !== false ) { unset ( $ this -> textStyles [ $ index ] ) ; } } | Removes a text style |
56,487 | public function add ( ICommand $ command , bool $ overwrite = false ) { if ( ! $ overwrite && $ this -> has ( $ command -> getName ( ) ) ) { throw new InvalidArgumentException ( "A command with name \"{$command->getName()}\" already exists" ) ; } $ command -> setCommandCollection ( $ this ) ; $ this -> commands [ $ com... | Adds a command |
56,488 | public function call ( string $ commandName , IResponse $ response , array $ arguments = [ ] , array $ options = [ ] ) { $ request = $ this -> requestParser -> parse ( [ 'name' => $ commandName , 'arguments' => $ arguments , 'options' => $ options ] ) ; $ compiledCommand = $ this -> commandCompiler -> compile ( $ this ... | Calls a command and writes its output to the input response |
56,489 | public function get ( string $ name ) : ICommand { if ( ! $ this -> has ( $ name ) ) { throw new InvalidArgumentException ( "No command with name \"$name\" exists" ) ; } return $ this -> commands [ $ name ] ; } | Gets the command with the input name |
56,490 | public static function getVar ( string $ name , $ default = null ) { if ( array_key_exists ( $ name , $ _ENV ) ) { return $ _ENV [ $ name ] ; } elseif ( array_key_exists ( $ name , $ _SERVER ) ) { return $ _SERVER [ $ name ] ; } else { $ value = getenv ( $ name ) ; if ( $ value === false ) { return $ default ; } return... | Gets the value of an environment variable |
56,491 | public static function setVar ( string $ name , $ value ) { if ( self :: getVar ( $ name ) === null ) { putenv ( "$name=$value" ) ; $ _ENV [ $ name ] = $ value ; $ _SERVER [ $ name ] = $ value ; } } | Sets an environment variable but does not overwrite existing variables |
56,492 | protected function getAuthenticator ( IContainer $ container ) : IAuthenticator { $ authenticatorRegistry = new AuthenticatorRegistry ( ) ; $ authenticator = new Authenticator ( $ authenticatorRegistry ) ; $ container -> bindInstance ( IAuthenticatorRegistry :: class , $ authenticatorRegistry ) ; return $ authenticator... | Gets the authenticator |
56,493 | public static function getAll ( ) : array { return [ self :: RSA_SHA256 , self :: RSA_SHA384 , self :: RSA_SHA512 , self :: SHA256 , self :: SHA384 , self :: SHA512 ] ; } | Gets all the supported algorithms |
56,494 | public static function isSymmetric ( $ algorithm ) : bool { if ( ! self :: has ( $ algorithm ) ) { throw new InvalidArgumentException ( "Algorithm \"$algorithm\" is not valid" ) ; } return in_array ( $ algorithm , [ Algorithms :: SHA256 , Algorithms :: SHA384 , Algorithms :: SHA512 ] ) ; } | Checks if an algorithm is symmetric |
56,495 | private function tokenShouldNotBeChecked ( Request $ request ) : bool { return in_array ( $ request -> getMethod ( ) , [ RequestMethods :: GET , RequestMethods :: HEAD , RequestMethods :: OPTIONS ] ) ; } | Gets whether or not the token should even be checked |
56,496 | private function connect ( ) { if ( ! $ this -> isConnected ) { parent :: __construct ( $ this -> dsn , $ this -> server -> getUsername ( ) , $ this -> server -> getPassword ( ) , $ this -> driverOptions ) ; parent :: setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; parent :: setAttribute ( PDO :: ATTR... | Attempts to connect to the server which is done via lazy - connecting |
56,497 | public function addStream ( IStream $ stream ) : void { if ( ! $ stream -> isReadable ( ) ) { throw new InvalidArgumentException ( 'Stream must be readable' ) ; } $ this -> isSeekable = $ this -> isSeekable && $ stream -> isSeekable ( ) ; $ this -> streams [ ] = $ stream ; } | Adds a stream to the multi - stream |
56,498 | protected function getSubjectFromUser ( IUser $ user , ICredential $ credential ) : ISubject { $ userId = $ user -> getId ( ) ; $ roles = $ this -> roleRepository -> getRoleNamesForSubject ( $ userId ) ; return new Subject ( [ new Principal ( PrincipalTypes :: PRIMARY , $ userId , $ roles ) ] , [ $ credential ] ) ; } | Gets a subject from a user |
56,499 | public function get ( string $ name ) { if ( ! array_key_exists ( $ name , $ this -> headers ) ) { return null ; } return $ this -> headers [ $ name ] ; } | Gets the value for a header |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.