idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
17,300
public function getPrefixedPath ( string $ path = '' ) : string { return trim ( $ this -> parent ? ( $ this -> parent -> getPrefixedPath ( $ this -> prefix ? $ this -> prefix . '/' . $ path : $ path ) ) : ( $ this -> prefix ? $ this -> prefix . '/' . $ path : $ path ) , '/' ) ; }
Gets path prefix of this context and all its parents
17,301
public function addMiddleware ( callable $ middleware , string $ type = self :: BEFORE ) { ; $ type = self :: validateMiddlewareType ( $ type ) ; $ this -> middlewares [ $ type ] [ ] = $ middleware ; }
Adds a new middleware to this context
17,302
public function addSubContext ( string $ prefix , Closure $ invoker ) : RoutingContext { return $ this -> contexts [ ] = new RoutingContext ( $ prefix , $ invoker , $ this ) ; }
Adds a new sub context to this context
17,303
function it_retains_the_original_state_of_the_instance_duplicated_with_new_scheme ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_scheme = $ this -> withScheme ( "http" ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified scheme .
17,304
function it_retains_the_original_state_of_the_instance_duplicated_with_new_authority ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_authority = $ this -> withAuthority ( "corge:grault@quux.qux:9999" ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified authority .
17,305
function it_replaces_authority_components_with_new_authority ( ) { $ new_authority = $ this -> withAuthority ( "corge:grault@quux.qux:9999" ) ; $ new_authority -> getAuthority ( ) -> shouldReturn ( "corge:grault@quux.qux:9999" ) ; $ new_authority -> getUserInfo ( ) -> shouldReturn ( "corge:grault" ) ; $ new_authority -> getHost ( ) -> shouldReturn ( "quux.qux" ) ; $ new_authority -> getPort ( ) -> shouldReturn ( 9999 ) ; }
Replacing the authority is equivalent to replacing or removing all authority components depending upon the composition of the authority .
17,306
function it_removes_authority_components_with_empty_authority ( ) { $ new_authority = $ this -> withAuthority ( "" ) ; $ new_authority -> getAuthority ( ) -> shouldReturn ( "" ) ; $ new_authority -> getUserInfo ( ) -> shouldReturn ( "" ) ; $ new_authority -> getHost ( ) -> shouldReturn ( "" ) ; $ new_authority -> getPort ( ) -> shouldReturn ( null ) ; }
An empty authority is equivalent to removing the authority and all authority components .
17,307
function it_retains_the_original_state_of_the_instance_duplicated_with_new_user_info ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_user_info = $ this -> withUserInfo ( "corge" , "grault" ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified user information .
17,308
function it_retains_the_original_state_of_the_instance_duplicated_with_a_new_host ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_host = $ this -> withHost ( "quux.qux" ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified host .
17,309
function it_retains_the_original_state_of_the_instance_duplicated_with_a_new_port ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_port = $ this -> withPort ( 9999 ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified port .
17,310
function it_retains_the_original_state_of_the_instance_duplicated_with_new_path ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_path = $ this -> withPath ( "/quux/quuz" ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified path .
17,311
function it_retains_the_original_state_of_the_instance_duplicated_with_new_query ( ) { $ original_uri = ( string ) $ this -> getWrappedObject ( ) ; $ new_query = $ this -> withQuery ( "garply" ) ; $ this -> __toString ( ) -> shouldReturn ( $ original_uri ) ; }
This method MUST retain the state of the current instance and return an instance that contains the specified query string .
17,312
public function supports ( $ template ) { foreach ( $ this -> engines as $ engine ) { if ( $ engine -> supports ( $ template ) ) { return true ; } } return false ; }
Checks if any of the engines can render the template .
17,313
public function exists ( $ template ) { foreach ( $ this -> engines as $ engine ) { if ( $ engine -> supports ( $ template ) ) { return $ engine -> exists ( $ template ) ; } } return false ; }
Checks if the template exists .
17,314
protected function GenerateConstantsClass ( $ files ) { if ( count ( $ files ) > 0 ) { $ classGen = new ConstantsClassGeneratorBase ( $ this -> params , $ files ) ; $ classGen -> BuildClass ( ) ; return str_replace ( '\\' , '/' , "file://" . "APP_ROOT_DIR" . $ this -> params [ BaseClassGenerator :: NameSpaceKey ] . "/" . $ classGen -> fileName ) ; } else { return "No class to generate." ; } }
Generate the Constant Class list the framework .
17,315
protected function GenerateFrameworkFile ( $ files ) { $ filePath = $ this -> GenerateConstantsClass ( $ files ) ; array_push ( $ this -> filesGenerated , $ filePath ) ; return $ filePath ; }
Generate the FrameworkControllers . php class .
17,316
public static function Eform ( iauRefEllips $ n , & $ a , & $ f ) { switch ( $ n -> value ) { case WGS84 : $ a = 6378137.0 ; $ f = 1.0 / 298.257223563 ; break ; case GRS80 : $ a = 6378137.0 ; $ f = 1.0 / 298.257222101 ; break ; case WGS72 : $ a = 6378135.0 ; $ f = 1.0 / 298.26 ; break ; default : $ a = 0.0 ; $ f = 0.0 ; return - 1 ; } return 0 ; }
- - - - - - - - - i a u E f o r m - - - - - - - - -
17,317
public static function mergeNatural ( array $ array1 , array $ array2 ) { if ( empty ( $ array1 ) ) { return $ array2 ; } $ result = $ array1 ; foreach ( $ array2 as $ key => $ value ) { if ( isset ( $ result [ $ key ] ) and is_array ( $ result [ $ key ] ) and is_array ( $ value ) ) { $ result [ $ key ] = static :: mergeNatural ( $ result [ $ key ] , $ value ) ; } elseif ( ( ! isset ( $ result [ $ key ] ) or ( ! is_null ( $ value ) ) ) ) { $ result [ $ key ] = $ value ; } } return $ result ; }
Merges two arrays recursive naturally Second array values takes precedence with exception that its value on particular place is null
17,318
public static function filterCaseInsensitively ( array $ needles , array $ haystack ) { $ result = array ( ) ; $ modifiedHaystack = array_change_key_case ( $ haystack , CASE_LOWER ) ; foreach ( $ needles as $ needle ) { $ modifiedNeedle = strtolower ( $ needle ) ; if ( array_key_exists ( $ needle , $ haystack ) ) { $ result [ $ needle ] = $ haystack [ $ needle ] ; } elseif ( array_key_exists ( $ modifiedNeedle , $ modifiedHaystack ) ) { $ result [ $ needle ] = $ modifiedHaystack [ $ modifiedNeedle ] ; } } return $ result ; }
Filter haystack using values in needles in case insensitive manner if needed
17,319
private function getItemBySource ( MappingInterface $ mapping , $ sourceSlug ) { if ( $ sourceSlug === $ mapping -> getLeftItem ( ) -> getSource ( ) -> getSlug ( ) ) { return $ mapping -> getLeftItem ( ) ; } return $ mapping -> getRightItem ( ) ; }
Get item by source .
17,320
public function _loadNotificationIntoQueue ( $ notification_entry ) { $ this -> queue_manager -> connection ( $ this -> queue_connection ) -> pushRaw ( json_encode ( $ notification_entry ) , $ this -> queue_name ) ; }
public for testing purposes
17,321
private function sortChildren ( ) { uasort ( $ this -> children , function ( MapperTreeItemInterface $ first , MapperTreeItemInterface $ second ) { if ( $ first -> getPriority ( ) >= $ second -> getPriority ( ) ) { return 1 ; } if ( $ first -> getPriority ( ) < $ second -> getPriority ( ) ) { return - 1 ; } } ) ; }
Sort item children .
17,322
public static function get ( array $ array , $ key , $ fallback = null ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) { return $ fallback ; } $ array = $ array [ $ key ] ; } return $ array ; }
Get value from array
17,323
public static function pop ( array $ array , $ key ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) { return null ; } $ array = $ array [ $ key ] ; } if ( ! is_array ( $ array ) ) { return null ; } return array_pop ( $ array ) ; }
Pop value from sub - array
17,324
public static function set ( array & $ array , $ key , $ value ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) { $ array [ $ key ] = [ ] ; } $ array = & $ array [ $ key ] ; } $ array = $ value ; }
Set value in array
17,325
public static function push ( array & $ array , $ key , $ value ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) { $ array [ $ key ] = [ ] ; } $ array = & $ array [ $ key ] ; } if ( ! is_array ( $ array ) ) { $ array = [ ] ; } array_push ( $ array , $ value ) ; }
Push value in sub - array
17,326
public static function drop ( array & $ array , $ key ) { $ keys = explode ( '.' , $ key ) ; $ last = array_pop ( $ keys ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) { return false ; } $ array = & $ array [ $ key ] ; } if ( isset ( $ array [ $ last ] ) ) { unset ( $ array [ $ last ] ) ; return true ; } return false ; }
Delete key in array
17,327
public function query ( $ query_string , Closure $ callback ) { $ query = $ this -> getQuery ( $ query_string ) ; $ query -> execute ( $ this , $ callback ) ; }
Execute a query using a closure to capture the results .
17,328
public function register ( $ identifier , $ value ) { parent :: register ( $ identifier , $ value ) ; $ sql = sprintf ( 'INSERT INTO %s (`entityId`, `data`) set (`%s`, `%s`);' , $ this -> mysql -> quote ( $ this -> section ) , $ this -> mysql -> quote ( $ identifier ) , $ this -> decorator -> normalizeValue ( $ value ) ) ; $ result = $ this -> mysql -> query ( $ sql ) ; if ( false === $ result ) { $ this -> registry [ $ this -> section ] [ $ identifier ] = null ; $ this -> throwException ( 'Error occurred while registering an entity: ' , $ this -> mysql -> errorInfo ( ) ) ; } }
Registers the provided value .
17,329
public function getContentById ( $ identifier , $ default = null ) { if ( empty ( $ this -> registry [ $ this -> section ] [ $ identifier ] ) ) { $ this -> registry [ $ this -> section ] [ $ identifier ] = $ this -> getContentByIds ( array ( $ identifier ) ) ; if ( empty ( $ this -> registry [ $ this -> section ] [ $ identifier ] ) ) { return $ default ; } } return $ this -> registry [ $ this -> section ] [ $ identifier ] ; }
Provides the registry content identified by its ID .
17,330
public function getContentByIds ( array $ identifiers ) { $ sql = sprintf ( 'SELECT * FROM %s WHERE entityId IN (`%s`);' , $ this -> mysql -> quote ( $ this -> section ) , implode ( '`,`' , $ identifiers ) ) ; $ result = $ this -> mysql -> query ( $ sql ) ; if ( false === $ result ) { $ this -> throwException ( 'Error occurred while querying the registry: ' , $ this -> mysql -> errorInfo ( ) ) ; } $ content = $ result -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ this -> registry [ $ this -> section ] = array_merge ( $ this -> registry [ $ this -> section ] , $ content ) ; return $ content ; }
Provides a set of registry items .
17,331
public function replace ( $ identifier , $ value ) { $ oldValue = @ $ this -> registry [ $ this -> section ] [ $ identifier ] ; parent :: replace ( $ identifier , $ value ) ; $ sql = sprintf ( 'UPDATE %s SET `data`=`%s` WHERE `entityId`=`%s`;' , $ this -> mysql -> quote ( $ this -> section ) , $ this -> mysql -> quote ( $ value ) , $ this -> mysql -> quote ( $ identifier ) ) ; $ result = $ this -> mysql -> exec ( $ sql ) ; if ( false === $ result ) { $ this -> registry [ $ this -> section ] [ $ identifier ] = $ oldValue ; $ this -> throwException ( 'Failed to fetch information from the registry: ' , $ this -> mysql -> errorInfo ( ) ) ; } }
Replaces the identified entity with the provided one .
17,332
public function destroy ( ) { $ sql = sprintf ( 'DROP TABLE `%s`;' , $ this -> mysql -> quote ( $ this -> section ) ) ; if ( false === $ this -> mysql -> exec ( $ sql ) ) { $ this -> throwException ( 'Unable to delete the database: ' , $ this -> mysql -> errorInfo ( ) ) ; } $ this -> registry [ $ this -> section ] = array ( ) ; }
Shall delete the current registry from the database .
17,333
public function init ( ) { $ this -> registryTableExists ( ) ; if ( empty ( $ this -> registry [ $ this -> section ] ) ) { $ this -> registry [ $ this -> section ] = $ this -> getContent ( ) ; } return $ this -> registry [ $ this -> section ] ; }
Shall register a new section in the registry
17,334
protected function registryTableExists ( ) { $ sql = sprintf ( 'SHOW CREATE TABLE `%s`;' , $ this -> mysql -> quote ( $ this -> section ) ) ; if ( false === $ this -> mysql -> query ( $ sql ) ) { $ this -> throwException ( 'The registry table does not exists: ' , $ this -> mysql -> errorInfo ( ) ) ; } }
Validates that the registry table exists .
17,335
public function getContent ( $ limit = 0 ) { $ this -> registry [ $ this -> section ] = parent :: getContent ( ) ; if ( empty ( $ this -> registry [ $ this -> section ] ) ) { $ sql = sprintf ( 'SELECT * FROM `%s`;' , $ this -> mysql -> quote ( $ this -> section ) ) ; $ result = $ this -> mysql -> query ( $ sql ) ; if ( false === $ result ) { $ this -> throwException ( 'Failed to fetch information from the registry: ' , $ this -> mysql -> errorInfo ( ) ) ; } $ this -> registry [ $ this -> section ] = $ this -> processResult ( $ result -> fetchAll ( \ PDO :: FETCH_ASSOC ) ) ; } return $ this -> registry [ $ this -> section ] ; }
Provides the current content of the registry .
17,336
protected function processResult ( array $ results ) { foreach ( $ results as $ key => $ entity ) { if ( ! empty ( $ entity [ 'data' ] ) ) { $ entity [ 'data' ] = $ this -> decorator -> denormalizeValue ( $ entity [ 'data' ] ) ; $ results [ $ key ] = $ entity ; } } return $ results ; }
Processes the results to return a denormalized entity set .
17,337
public static function allInRangeOrAll ( $ value , $ minValue , $ maxValue ) { if ( is_array ( $ value ) ) { static :: allRange ( $ value , $ minValue , $ maxValue ) ; return ; } static :: eq ( $ value , 'all' ) ; }
Assert that value is a range of numbers or the string all
17,338
public static function choicesIsset ( array $ values , array $ choices ) { self :: notEmpty ( $ values , null , null ) ; foreach ( $ choices as $ choice ) { self :: keyIsset ( $ values , $ choice , null , null ) ; } }
Determines if the values array has every choice as key and that this choice has content .
17,339
public static function ip ( $ value ) { if ( ! is_string ( $ value ) and ! filter_var ( $ value , FILTER_VALIDATE_IP ) ) { $ message = sprintf ( 'Value "%s" expected to be a valid IP address.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_IP , null ) ; } }
Assert that value is a valid IP address
17,340
protected function getCommands ( array $ config ) { if ( ! is_array ( $ config [ 'plugins' ] ) ) { throw new \ RuntimeException ( 'Configuration "plugins" key must reference an array' , self :: ERR_PLUGINS_NONARRAY ) ; } $ plugins = array_filter ( $ config [ 'plugins' ] , function ( $ plugin ) { return $ plugin instanceof PluginInterface ; } ) ; if ( count ( $ plugins ) != count ( $ config [ 'plugins' ] ) ) { throw new \ RuntimeException ( 'All configuration "plugins" array values must implement \Phergie\Irc\Bot\React\PluginInterface' , self :: ERR_PLUGINS_NONPLUGINS ) ; } $ commands = array ( ) ; foreach ( $ plugins as $ plugin ) { $ events = array_keys ( $ plugin -> getSubscribedEvents ( ) ) ; $ commandEvents = array ( ) ; foreach ( $ events as $ event ) { if ( ! preg_match ( '/^command\.(.+)\.help$/' , $ event , $ match ) ) { continue ; } $ commands [ $ match [ 1 ] ] = true ; } } return $ this -> alphabetize ( $ commands ) ; }
Extracts command information from configuration .
17,341
public function handleHelpCommand ( CommandEvent $ event , EventQueueInterface $ queue ) { $ params = $ event -> getCustomParams ( ) ; if ( $ params ) { $ command = strtolower ( reset ( $ params ) ) ; $ eventName = 'command.' . $ command . '.help' ; $ this -> getEventEmitter ( ) -> emit ( $ eventName , array ( $ event , $ queue ) ) ; } else { $ this -> listCommands ( $ event , $ queue ) ; } }
Responds to the help command .
17,342
protected function listCommands ( CommandEvent $ event , EventQueueInterface $ queue ) { $ targets = $ event -> getTargets ( ) ; $ target = reset ( $ targets ) ; $ nick = $ event -> getNick ( ) ; if ( $ target === $ event -> getConnection ( ) -> getNickname ( ) ) { $ target = $ nick ; $ address = '' ; } else { $ address = $ nick . ': ' ; } $ method = 'irc' . $ event -> getCommand ( ) ; $ message = $ address . $ this -> listText . implode ( ' ' , $ this -> commands ) ; $ queue -> $ method ( $ target , $ message ) ; }
Responds to a parameter - less help command with a list of available commands .
17,343
private function alphabetize ( $ commands ) { $ commandList = array_keys ( $ commands ) ; sort ( $ commandList , SORT_NATURAL | SORT_FLAG_CASE ) ; return array_values ( $ commandList ) ; }
Sort array of commands
17,344
public function isLoggedIn ( ) { $ loggedIn = $ this -> di -> get ( "session" ) -> has ( "user" ) ; if ( ! $ loggedIn ) { $ this -> di -> get ( "response" ) -> redirect ( "user/login" ) ; return false ; } return true ; }
Check if user is logged in .
17,345
public function isAdmin ( $ redirect = false ) { if ( ! $ this -> isLoggedIn ( ) ) { $ this -> di -> get ( "response" ) -> redirect ( "user/login" ) ; return false ; } $ email = $ this -> di -> get ( "session" ) -> get ( "user" ) ; $ user = new User ( ) ; $ user -> setDb ( $ this -> di -> get ( "db" ) ) ; $ user -> find ( "email" , $ email ) ; $ isAdmin = $ user -> admin ; if ( ! $ isAdmin ) { if ( $ redirect ) { $ this -> di -> get ( "response" ) -> redirect ( "user" ) ; } return false ; } return true ; }
Check if user is admin
17,346
public function hasAccessToComment ( $ commentID ) { $ this -> isLoggedIn ( ) ; $ userid = $ this -> di -> get ( "session" ) -> get ( "userid" ) ; $ comment = new Comment ( ) ; $ comment -> setDb ( $ this -> di -> get ( "db" ) ) ; $ user = new User ( ) ; $ user -> setDb ( $ this -> di -> get ( "db" ) ) ; $ user -> find ( "id" , $ userid ) ; $ comment -> find ( "id" , $ commentID ) ; if ( ( $ comment -> user_id == $ userid ) || $ this -> isAdmin ( ) ) { return true ; } $ this -> di -> get ( "response" ) -> redirect ( "user" ) ; return false ; }
Check if the user have access to the comment
17,347
public function load ( \ Zend_EventManager_EventDescription $ event ) { if ( false !== ( $ content = $ this -> cache -> load ( $ this -> _getIdentifier ( $ event ) ) ) ) { $ event -> stopPropagation ( true ) ; return $ content ; } }
Pre event - try load content from cache
17,348
public function save ( \ Zend_EventManager_EventDescription $ event ) { $ params = $ event -> getParams ( ) ; if ( ! isset ( $ params [ 'data' ] ) ) { throw new \ Zend_EventManager_Exception_InvalidArgumentException ( 'Missing param data.' ) ; } $ this -> cache -> save ( $ params [ 'data' ] , $ this -> _getIdentifier ( $ event ) , $ this -> _getTags ( $ event ) ) ; }
Post event - save content in cache
17,349
public function clean ( \ Zend_EventManager_EventDescription $ event ) { $ params = $ event -> getParams ( ) ; $ mode = \ Zend_Cache :: CLEANING_MODE_MATCHING_ANY_TAG ; if ( isset ( $ params [ 'mode' ] ) ) { $ mode = $ params [ 'mode' ] ; } return $ this -> cache -> clean ( $ mode , $ this -> _getTags ( $ event ) ) ; }
Clear event - clear all cache by tags
17,350
protected function _getIdentifier ( \ Zend_EventManager_EventDescription $ event ) { $ params = $ event -> getParams ( ) ; if ( ! isset ( $ params [ 'id' ] ) ) { throw new \ Zend_EventManager_Exception_InvalidArgumentException ( 'Missing param id.' ) ; } return md5 ( $ this -> _getClassName ( $ event -> getTarget ( ) ) . '-' . $ params [ 'id' ] ) ; }
Method return identifier name from class and id
17,351
protected function _getClassName ( $ target ) { $ className = $ target ; if ( is_object ( $ target ) ) { $ className = get_class ( $ target ) ; } return $ this -> _normalizeName ( $ className ) ; }
Method return target class name
17,352
protected function _getTags ( \ Zend_EventManager_EventDescription $ event ) { $ params = $ event -> getParams ( ) ; $ tags = array ( $ this -> _getClassName ( $ event -> getTarget ( ) ) ) ; if ( isset ( $ params [ 'tags' ] ) ) { if ( is_array ( $ params [ 'tags' ] ) ) { $ tags = array_merge ( $ tags , $ params [ 'tags' ] ) ; } else { $ tags [ ] = $ params [ 'tags' ] ; } } foreach ( $ tags as & $ tag ) { $ tag = $ this -> _normalizeName ( $ tag ) ; } return $ tags ; }
Method return array of tags from event
17,353
public function merge ( DateLexerResult $ result ) { $ this -> offset = $ result -> offset ; $ this -> data = array_merge ( $ this -> data , $ result -> data ) ; }
Merges a result into this one .
17,354
public function getFirst ( $ name ) { $ names = func_get_args ( ) ; foreach ( $ names as $ name ) { if ( isset ( $ this -> data [ $ name ] ) ) { return $ this -> data [ $ name ] ; } } }
Get first set symbol value .
17,355
public function cdn ( $ name , $ url , $ type = null ) { if ( $ type === null ) { $ type = substr ( strrchr ( $ url , '.' ) , 1 ) ; } $ group = config ( 'assetprocessor.attributes.group.cdn' , 'cdn' ) ; $ this -> files [ $ type ] [ $ group ] [ $ name ] = $ url ; }
Used in order to allow for the use of a CDN for assets .
17,356
public function generateSingularFile ( $ type , $ group , $ directory ) { if ( ! isset ( $ this -> files [ $ type ] [ $ group ] ) ) { return null ; } $ assets = $ this -> files [ $ type ] [ $ group ] ; return $ this -> write ( $ type , $ assets , $ directory ) ; }
Generates a singular file that contains all of the specific asset files .
17,357
private function deriveProcessingEnabled ( ) { if ( config ( 'assetprocessor.enabled.force' , false ) ) { $ this -> processingEnabled = true ; } else { $ this -> processingEnabled = in_array ( App :: environment ( ) , config ( 'assetprocessor.enabled.environments' , array ( ) ) ) ; } }
Used internally in order to determine whether or not we need to actually process the input files .
17,358
private function setupLibraries ( ) { $ processors = config ( 'assetprocessor.processors.types' , array ( ) ) ; $ interface = config ( 'assetprocessor.processors.interface' ) ; foreach ( $ processors as $ name => $ class ) { $ instance = $ class :: getInstance ( $ this -> processingEnabled ) ; if ( ! ( $ instance instanceof $ interface ) ) { throw new Exception ( Lang :: get ( 'assetprocessor::errors.asset.invalid-type' , array ( 'class' => $ class , 'interface' => $ interface ) ) ) ; } $ this -> processors [ $ name ] = $ instance ; $ this -> deriveExtensionMapping ( $ name , $ class :: getAssociatedExtensions ( ) ) ; if ( ! isset ( $ this -> files [ $ instance -> getAssetType ( ) ] ) ) { $ this -> files [ $ instance -> getAssetType ( ) ] = array ( ) ; } } }
Used internally in order to set up an instance of each of the processors that we will need .
17,359
private function deriveExtensionMapping ( $ name , array $ extensions ) { foreach ( $ extensions as $ extension ) { if ( ! isset ( $ this -> extensionMapping [ $ extension ] ) ) { $ this -> extensionMapping [ $ extension ] = array ( ) ; } $ this -> extensionMapping [ $ extension ] [ ] = $ name ; } }
Used internally in order to derive the list of extensions that are used by a particular processor .
17,360
private function write ( $ type , $ contents , $ directory = null ) { $ file = '' ; $ directory = $ directory === null ? static :: storageFolder ( ) : ( $ directory . '/' ) ; $ directory .= $ type . '/' ; if ( is_array ( $ contents ) ) { foreach ( $ contents as $ filename ) { if ( ! file_exists ( $ filename ) ) { $ filename = $ directory . $ filename ; } $ file .= file_get_contents ( $ filename ) ; } } else { if ( ! file_exists ( $ contents ) ) { $ contents = $ directory . $ contents ; } $ file .= file_get_contents ( $ contents ) ; } $ filename = md5 ( $ file ) ; if ( ! file_exists ( $ directory ) ) { mkdir ( $ directory , 0777 , true ) ; } file_put_contents ( $ directory . $ filename , $ file ) ; return $ filename ; }
Used internally in order to write all of the contents for the provided files into a single file .
17,361
private function autoLoadAssets ( ) { foreach ( config ( 'assetprocessor.autoload.cdn' , array ( ) ) as $ asset ) { self :: cdn ( $ asset , $ asset ) ; } foreach ( config ( 'assetprocessor.autoload.local' , array ( ) ) as $ asset ) { self :: add ( $ asset , $ asset ) ; } }
Used internally in order to help with the auto - loading of all of the assets .
17,362
private function setupDirectories ( ) { if ( ! file_exists ( $ dir = config ( 'assetprocessor.cache.directory' ) ) ) { mkdir ( $ dir , 0777 , true ) ; } if ( ! file_exists ( $ dir = config ( 'assetprocessor.cache.external' , config ( 'assetprocessor.cache.directory' ) ) ) ) { mkdir ( $ dir , 0777 , true ) ; } if ( ! file_exists ( $ dir = config ( 'assetprocessor.cache.external' , config ( 'assetprocessor.cache.directory' ) ) . '/css' ) ) { mkdir ( $ dir , 0777 , true ) ; } if ( ! file_exists ( $ dir = config ( 'assetprocessor.cache.external' , config ( 'assetprocessor.cache.directory' ) ) . '/js' ) ) { mkdir ( $ dir , 0777 , true ) ; } }
Sets up all of the base directories that the plugin will need to run .
17,363
public function set ( $ key , $ value ) { if ( ! $ value instanceof EntityMapperInterface ) { throw new InvalidArgumentException ( 'Trying to add a non EntityMapper to MappersMap.' ) ; } return parent :: set ( $ key , $ value ) ; }
Puts a new Entity mapper in the map .
17,364
public static final function configuration ( string $ locale ) { if ( ! empty ( $ locale ) ) { Lang :: $ locale = $ locale ; } else { Lang :: $ locale = Lang :: STANDARD_LOCALE ; } return null ; }
- Define configuration locate of language
17,365
public static final function addRoot ( string $ package , string $ path ) { if ( ! empty ( $ package ) && ! empty ( $ path ) ) { $ dirname = realpath ( Path :: replaceOSSeparator ( $ path ) ) ; if ( is_dir ( $ dirname ) ) { Lang :: $ root [ $ package ] = $ dirname ; } } return null ; }
- Define root of find of packages
17,366
public static final function get ( string $ identify , string $ package , Array $ data = null ) : string { $ text = $ identify ; if ( ! empty ( $ identify ) ) { if ( $ language = Lang :: loadPackage ( $ package ) ) { if ( isset ( $ language -> { $ identify } ) ) { $ text = Lang :: replace ( $ language -> { $ identify } , $ data ) ; } } } return $ text ; }
- Identify TAG and package and return text
17,367
private static function loadPackage ( string $ package ) : stdClass { $ language = new stdClass ( ) ; if ( ! empty ( $ package ) ) { $ filename = null ; if ( $ packageData = explode ( ":" , $ package ) ) { if ( ! empty ( $ packageData [ 0 ] ) ) { $ filename .= Lang :: $ root [ $ packageData [ 0 ] ] ; } if ( ! empty ( $ packageData [ 1 ] ) ) { $ filename .= DIRECTORY_SEPARATOR . $ packageData [ 1 ] ; } $ pathaname = Lang :: selectPackage ( $ filename ) ; if ( file_exists ( $ pathaname ) ) { $ pathaname = Path :: replaceOSSeparator ( $ pathaname ) ; $ decode = json_decode ( file_get_contents ( ( new SplFileObject ( $ pathaname , "r" ) ) -> getPathname ( ) ) ) ; $ language = ( JSON_ERROR_NONE == json_last_error ( ) ) ? $ decode : $ language ; } } } return $ language ; }
- Identify package and load package language
17,368
private static function selectPackage ( string $ pathname ) : string { $ filename = $ pathname . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang :: $ locale . ".json" ; if ( file_exists ( $ filename ) ) { $ pathname = $ filename ; } else { $ pathname .= DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . Lang :: STANDARD_LOCALE . ".json" ; } return $ pathname ; }
- Select package defined in configuration case not exist package select standard package
17,369
private static function replace ( string $ text , Array $ data = null ) : string { if ( ! empty ( $ text ) && count ( $ data ) ) { if ( $ metaText = ( new ReplaceText ( ) ) -> replace ( $ text , $ data ) ) { $ text = $ metaText ; } } return $ text ; }
- Replace TAGs in text
17,370
public function findByTypesAndNames ( array $ namesByTypes , array $ modCombinationIds = [ ] ) : array { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'i' ) -> from ( Item :: class , 'i' ) ; $ index = 0 ; $ conditions = [ ] ; foreach ( $ namesByTypes as $ type => $ names ) { $ conditions [ ] = '(i.type = :type' . $ index . ' AND i.name IN (:names' . $ index . '))' ; $ queryBuilder -> setParameter ( 'type' . $ index , $ type ) -> setParameter ( 'names' . $ index , array_values ( $ names ) ) ; ++ $ index ; } $ result = [ ] ; if ( $ index > 0 ) { $ queryBuilder -> andWhere ( '(' . implode ( ' OR ' , $ conditions ) . ')' ) ; if ( count ( $ modCombinationIds ) > 0 ) { $ queryBuilder -> innerJoin ( 'i.modCombinations' , 'mc' ) -> andWhere ( 'mc.id IN (:modCombinationIds)' ) -> setParameter ( 'modCombinationIds' , array_values ( $ modCombinationIds ) ) ; } $ result = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; } return $ result ; }
Finds the items with the specified types and names .
17,371
public function findByIds ( array $ ids ) : array { $ result = [ ] ; if ( count ( $ ids ) > 0 ) { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'i' ) -> from ( Item :: class , 'i' ) -> andWhere ( 'i.id IN (:ids)' ) -> setParameter ( 'ids' , array_values ( $ ids ) ) ; $ result = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; } return $ result ; }
Finds the items with the specified ids .
17,372
public function findByKeywords ( array $ keywords , array $ modCombinationIds = [ ] ) : array { $ result = [ ] ; if ( count ( $ keywords ) > 0 ) { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'i' ) -> from ( Item :: class , 'i' ) ; $ index = 0 ; foreach ( $ keywords as $ keyword ) { $ queryBuilder -> andWhere ( 'i.name LIKE :keyword' . $ index ) -> setParameter ( 'keyword' . $ index , '%' . addcslashes ( $ keyword , '\\%_' ) . '%' ) ; ++ $ index ; } if ( count ( $ modCombinationIds ) > 0 ) { $ queryBuilder -> innerJoin ( 'i.modCombinations' , 'mc' ) -> andWhere ( 'mc.id IN (:modCombinationIds)' ) -> setParameter ( 'modCombinationIds' , array_values ( $ modCombinationIds ) ) ; } $ result = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; } return $ result ; }
Finds the items matching the specified keywords .
17,373
public function findRandom ( int $ numberOfItems , array $ modCombinationIds = [ ] ) : array { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( [ 'i' , 'RAND() AS HIDDEN rand' ] ) -> from ( Item :: class , 'i' ) -> addOrderBy ( 'rand' ) -> setMaxResults ( $ numberOfItems ) ; if ( count ( $ modCombinationIds ) > 0 ) { $ queryBuilder -> innerJoin ( 'i.modCombinations' , 'mc' ) -> andWhere ( 'mc.id IN (:modCombinationIds)' ) -> setParameter ( 'modCombinationIds' , array_values ( $ modCombinationIds ) ) ; } return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Finds random items .
17,374
public function removeOrphans ( ) : void { $ itemIds = $ this -> findOrphanedIds ( ) ; if ( count ( $ itemIds ) > 0 ) { $ this -> removeIds ( $ itemIds ) ; } }
Removes any orphaned items i . e . items no longer used by any recipe or combination .
17,375
protected function findOrphanedIds ( ) : array { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'i.id AS id' ) -> from ( Item :: class , 'i' ) -> leftJoin ( 'i.modCombinations' , 'mc' ) -> leftJoin ( RecipeIngredient :: class , 'ri' , 'WITH' , 'ri.item = i.id' ) -> leftJoin ( RecipeProduct :: class , 'rp' , 'WITH' , 'rp.item = i.id' ) -> andWhere ( 'mc.id IS NULL' ) -> andWhere ( 'ri.item IS NULL' ) -> andWhere ( 'rp.item IS NULL' ) ; $ result = [ ] ; foreach ( $ queryBuilder -> getQuery ( ) -> getResult ( ) as $ data ) { $ result [ ] = ( int ) $ data [ 'id' ] ; } return $ result ; }
Returns the ids of orphaned machines which are no longer used by any recipe or combination .
17,376
protected function removeIds ( array $ itemIds ) : void { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> delete ( Item :: class , 'i' ) -> andWhere ( 'i.id IN (:itemIds)' ) -> setParameter ( 'itemIds' , array_values ( $ itemIds ) ) ; $ queryBuilder -> getQuery ( ) -> execute ( ) ; }
Removes the items with the specified ids from the database .
17,377
public static function Pfw06 ( $ date1 , $ date2 , & $ gamb , & $ phib , & $ psib , & $ epsa ) { $ t ; $ t = ( ( $ date1 - DJ00 ) + $ date2 ) / DJC ; $ gamb = ( - 0.052928 + ( 10.556378 + ( 0.4932044 + ( - 0.00031238 + ( - 0.000002788 + ( 0.0000000260 ) * $ t ) * $ t ) * $ t ) * $ t ) * $ t ) * DAS2R ; $ phib = ( 84381.412819 + ( - 46.811016 + ( 0.0511268 + ( 0.00053289 + ( - 0.000000440 + ( - 0.0000000176 ) * $ t ) * $ t ) * $ t ) * $ t ) * $ t ) * DAS2R ; $ psib = ( - 0.041775 + ( 5038.481484 + ( 1.5584175 + ( - 0.00018522 + ( - 0.000026452 + ( - 0.0000000148 ) * $ t ) * $ t ) * $ t ) * $ t ) * $ t ) * DAS2R ; $ epsa = IAU :: Obl06 ( $ date1 , $ date2 ) ; return ; }
- - - - - - - - - i a u P f w 0 6 - - - - - - - - -
17,378
public function permissions ( ) { if ( ! isset ( $ this -> permissions ) ) { $ permissionModel = $ this :: $ permissionModel ; $ this -> permissions = $ permissionModel :: whereHas ( 'roles' , function ( $ query ) { $ query -> whereHas ( 'users' , function ( $ query ) { $ query -> where ( 'id' , $ this -> id ) ; } ) ; } ) -> get ( ) ; } return $ this -> permissions ; }
Get the user permissions .
17,379
public function hasAnyPermission ( $ permissions ) { $ permissions = is_array ( $ permissions ) ? $ permissions : func_get_args ( ) ; foreach ( $ permissions as $ permission ) { if ( $ this -> permissions ( ) -> contains ( 'name' , $ permission ) ) return true ; } return false ; }
Determines if user has ANY given permissions .
17,380
protected function cropDefaults ( $ fpSrc , $ vals ) { $ this -> debug -> groupcollapsed ( __METHOD__ ) ; if ( empty ( $ vals [ 'src_type' ] ) || empty ( $ vals [ 'src_w' ] ) || empty ( $ vals [ 'src_h' ] ) ) { $ imageInfo = $ fpSrc == 'data' ? getimagesizefromstring ( $ vals [ 'src_data' ] ) : getimagesize ( $ fpSrc ) ; if ( $ imageInfo ) { $ imageInfoVals = array ( 'src_type' => $ imageInfo [ 2 ] , 'src_w' => $ imageInfo [ 0 ] , 'src_h' => $ imageInfo [ 1 ] , ) ; foreach ( array ( 'src_type' , 'src_w' , 'src_h' ) as $ k ) { if ( empty ( $ vals [ $ k ] ) ) { $ vals [ $ k ] = $ imageInfoVals [ $ k ] ; } } } } foreach ( array ( 'src_type' , 'dst_type' ) as $ type ) { if ( is_int ( $ vals [ $ type ] ) ) { $ vals [ $ type ] = image_type_to_extension ( $ vals [ $ type ] , false ) ; } elseif ( $ vals [ $ type ] == 'jpg' ) { $ vals [ $ type ] = 'jpeg' ; } } if ( empty ( $ vals [ 'dst_w' ] ) ) { $ vals [ 'dst_w' ] = $ vals [ 'src_w' ] ; } if ( empty ( $ vals [ 'dst_h' ] ) ) { $ vals [ 'dst_h' ] = $ vals [ 'src_h' ] ; } if ( is_string ( $ vals [ 'color_bg' ] ) ) { $ vals [ 'color_bg' ] = array_values ( $ this -> hex2rgb ( $ vals [ 'color_bg' ] ) ) ; } if ( empty ( $ vals [ 'opts' ] ) ) { $ quality = $ vals [ 'quality' ] ; if ( $ vals [ 'dst_type' ] == 'png' ) { $ vals [ 'quality' ] = round ( abs ( ( $ quality - 100 ) / 11.111111 ) ) ; } $ vals [ 'opts' ] = array ( $ vals [ 'quality' ] ) ; } $ this -> debug -> groupEnd ( ) ; return $ vals ; }
get default & normalize crop parameters
17,381
public function getConstrainedDimensions ( $ curW , $ curH , $ maxW , $ maxH ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ ratio = $ curW / $ curH ; $ return = array ( 'w' => $ curW , 'h' => $ curH ) ; if ( $ return [ 'w' ] > $ maxW ) { $ this -> debug -> log ( 'fitting to maxW' ) ; $ return = array ( 'w' => $ maxW , 'h' => round ( $ maxW / $ ratio ) ) ; } if ( $ return [ 'h' ] > $ maxH ) { $ this -> debug -> log ( 'fitting to maxH' ) ; $ return = array ( 'w' => round ( $ maxH * $ ratio ) , 'h' => $ maxH ) ; } $ this -> debug -> groupEnd ( ) ; return $ return ; }
Get the dimensions to fit an image to maxw and maxH
17,382
public function hex2rgb ( $ str_hex , $ returnAsString = false , $ seperator = ',' ) { $ str_hex = preg_replace ( "/[^0-9A-Fa-f]/" , '' , $ str_hex ) ; $ rgbArray = array ( ) ; $ return = false ; if ( strlen ( $ str_hex ) == 6 ) { $ colorVal = hexdec ( $ str_hex ) ; $ rgbArray = array ( 'red' => 0xFF & ( $ colorVal >> 0x10 ) , 'green' => 0xFF & ( $ colorVal >> 0x8 ) , 'blue' => 0xFF & $ colorVal , ) ; } elseif ( strlen ( $ str_hex ) == 3 ) { $ rgbArray = array ( 'red' => hexdec ( str_repeat ( substr ( $ str_hex , 0 , 1 ) , 2 ) ) , 'green' => hexdec ( str_repeat ( substr ( $ str_hex , 1 , 1 ) , 2 ) ) , 'blue' => hexdec ( str_repeat ( substr ( $ str_hex , 2 , 1 ) , 2 ) ) , ) ; } if ( ! empty ( $ rgbArray ) ) { $ return = $ returnAsString ? implode ( $ seperator , $ rgbArray ) : $ rgbArray ; } return $ return ; }
Convert a hexadecimal color code to its RGB equivalent
17,383
public function imagebmp ( & $ img , $ filename = false ) { $ wid = imagesx ( $ img ) ; $ hei = imagesy ( $ img ) ; $ wid_pad = str_pad ( '' , $ wid % 4 , "\0" ) ; $ size = 54 + ( $ wid + $ wid_pad ) * $ hei ; $ header = array ( 'identifier' => 'BM' , 'file_size' => $ this -> dword ( $ size ) , 'reserved' => $ this -> dword ( 0 ) , 'bitmap_data' => $ this -> dword ( 54 ) , 'header_size' => $ this -> dword ( 40 ) , 'width' => $ this -> dword ( $ wid ) , 'height' => $ this -> dword ( $ hei ) , 'planes' => $ this -> word ( 1 ) , 'bits_per_pixel' => $ this -> word ( 24 ) , 'compression' => $ this -> dword ( 0 ) , 'data_size' => $ this -> dword ( 0 ) , 'h_resolution' => $ this -> dword ( 0 ) , 'v_resolution' => $ this -> dword ( 0 ) , 'colors' => $ this -> dword ( 0 ) , 'important_colors' => $ this -> dword ( 0 ) , ) ; if ( $ filename ) { $ fh = fopen ( $ filename , "wb" ) ; foreach ( $ header as $ h ) { fwrite ( $ fh , $ h ) ; } for ( $ y = $ hei - 1 ; $ y >= 0 ; $ y -- ) { for ( $ x = 0 ; $ x < $ wid ; $ x ++ ) { $ rgb = imagecolorat ( $ img , $ x , $ y ) ; fwrite ( $ fh , $ this -> byte3 ( $ rgb ) ) ; } fwrite ( $ fh , $ wid_pad ) ; } return fclose ( $ fh ) ; } else { foreach ( $ header as $ h ) { echo $ h ; } for ( $ y = $ hei - 1 ; $ y >= 0 ; $ y -- ) { for ( $ x = 0 ; $ x < $ wid ; $ x ++ ) { $ rgb = imagecolorat ( $ img , $ x , $ y ) ; echo $ this -> byte3 ( $ rgb ) ; } echo $ wid_pad ; } return true ; } }
Save 24bit BMP file
17,384
public function isImage ( $ filepath ) { $ this -> debug -> groupCollapsed ( __METHOD__ , $ filepath ) ; $ isImage = false ; if ( false && function_exists ( 'exif_imagetype' ) ) { $ type = exif_imagetype ( $ filepath ) ; $ isImage = ( $ type !== false && in_array ( $ type , $ this -> imagetypes ) ) ; } else { $ imageInfo = getimagesize ( $ filepath ) ; $ mime = $ imageInfo [ 'mime' ] ; $ isImage = ( isset ( $ this -> imageTypes [ $ mime ] ) && $ imageInfo [ 0 ] && $ imageInfo [ 1 ] ) ; } $ this -> debug -> groupEnd ( ) ; return $ isImage ; }
is the file a supported image?
17,385
public function passthru ( $ filepath , $ info = array ( ) ) { $ this -> debug -> group ( __METHOD__ ) ; $ info = array_merge ( array ( 'filename' => null , 'md5' => null , 'mime' => 'image/jpeg' , 'size' => null , ) , $ info ) ; if ( file_exists ( $ filepath ) ) { if ( empty ( $ info [ 'md5' ] ) ) { $ info [ 'md5' ] = md5_file ( $ filepath ) ; } if ( empty ( $ info [ 'size' ] ) ) { $ info [ 'size' ] = filesize ( $ filepath ) ; } $ headers = apache_request_headers ( ) ; $ this -> debug -> log ( 'headers' , $ headers ) ; $ this -> debug -> log ( 'info[md5]' , $ info [ 'md5' ] ) ; if ( isset ( $ headers [ 'If-None-Match' ] ) && $ headers [ 'If-None-Match' ] == $ info [ 'md5' ] ) { header ( 'HTTP/1.1 304 Not Modified' ) ; } else { header ( 'Content-Type: ' . $ info [ 'mime' ] ) ; header ( 'ETag: ' . $ info [ 'md5' ] ) ; header ( 'Content-Length: ' . $ info [ 'size' ] ) ; header ( 'Last Modified: ' . gmdate ( 'D, d M Y H:i:s \G\M\T' ) ) ; if ( $ info [ 'filename' ] ) { header ( 'Content-Disposition: inline; filename="' . $ info [ 'filename' ] . '"' ) ; } readfile ( $ filepath ) ; } } else { $ this -> debug -> warn ( 'file does not exist' , $ filepath ) ; } $ this -> debug -> groupEnd ( ) ; return ; }
Output image with headers
17,386
public function make ( $ items , $ total , $ pageSize = 10 ) { $ this -> total = abs ( $ total ) ; $ this -> pageSize = $ pageSize ; $ this -> items = $ items ; return $ this ; }
Make a pagination
17,387
public function getCurrentPage ( $ total = null ) { $ page = abs ( app ( ) -> request -> get ( 'page' , 1 ) ) ; if ( $ total ) { $ this -> total = $ total ; } $ page >= 1 || $ page = 1 ; if ( $ this -> items ) { $ totalPage = $ this -> getTotalPage ( ) ; $ page <= $ totalPage || $ page = $ totalPage ; } return $ page ; }
Return current page
17,388
public function getTotalPage ( ) { $ this -> pageSize > 0 || $ this -> pageSize = 10 ; $ totalPage = ceil ( $ this -> total / $ this -> pageSize ) ; $ totalPage >= 1 || $ totalPage = 1 ; return $ totalPage ; }
Return total pages
17,389
public function replace ( array $ elements = array ( ) ) { $ this -> elements = array ( ) ; foreach ( $ elements as $ element ) { $ this -> add ( $ element ) ; } }
Replace the contents of this bag with the specified elements
17,390
public function appendRoute ( Route $ route ) { if ( ! $ originalRoute = optional ( $ this -> routes ) [ $ route -> slug ( ) ] ) { return "Route {$route->slug()} not found" ; } return $ this -> routes [ $ route -> slug ( ) ] [ 'groups' ] = $ originalRoute [ 'groups' ] -> merge ( $ route -> get ( ) [ 'groups' ] ) ; }
Append additional groups to an existing Route
17,391
public static function isTimestamp ( $ tstamp ) { return ( ( string ) ( int ) $ tstamp === $ tstamp ) && ( $ tstamp <= PHP_INT_MAX ) && ( $ tstamp >= ~ PHP_INT_MAX ) ; }
Checks that a string is a timestamp
17,392
public static function isIP ( $ address ) { $ parts = explode ( '.' , $ address ) ; if ( sizeof ( $ parts ) != 4 ) { return false ; } foreach ( $ parts as $ part ) : if ( empty ( $ part ) || ! static :: number ( $ part ) || $ part > 255 ) { return false ; } endforeach ; return true ; }
Validates an ip address format
17,393
protected function retrieveAllFiles ( array $ paths ) { $ files = [ ] ; foreach ( $ paths as $ path ) { $ newFiles = [ ] ; try { $ newFiles = $ this -> retrieveFiles ( $ path ) ; } catch ( FileSystemException $ e ) { continue ; } finally { $ files = array_merge ( $ files , $ newFiles ) ; } } return $ files ; }
Retrieve all yaml files from an array of directories .
17,394
protected function retrieveFiles ( string $ directory ) : array { $ files = [ ] ; foreach ( scandir ( $ directory ) as $ file ) { $ elem = $ this -> pathHelper -> join ( $ directory , $ file ) ; if ( $ elem != '.' && $ elem != '..' && \ is_file ( $ elem ) && \ is_readable ( $ elem ) && $ this -> stringHelper -> endsWith ( $ elem , '.yaml' ) ) { $ files [ ] = $ elem ; } } if ( count ( $ files ) == 0 ) { throw new FileSystemException ( 'Path does not contain any readable yaml files!' , 1527452904 ) ; } return $ files ; }
Retrieve all yaml files from a directory .
17,395
public function has ( string $ key ) : bool { if ( strpos ( $ key , '.' ) != false ) { return $ this -> getNested ( $ key ) != null ; } return array_key_exists ( $ key , $ this -> settings ) ; }
Checks if a key is present in the settings .
17,396
public function get ( string $ key = null ) { if ( empty ( $ key ) ) { return $ this -> settings ; } if ( \ strpos ( $ key , '.' ) != false ) { return $ this -> getNested ( $ key ) ; } if ( $ this -> has ( $ key ) ) { return $ this -> settings [ $ key ] ; } return null ; }
Retrieves data from the settings .
17,397
protected function getNested ( string $ key ) { $ parts = explode ( '.' , $ key ) ; $ result = $ this -> settings [ $ parts [ 0 ] ] ; for ( $ i = 1 ; $ i < count ( $ parts ) ; ++ $ i ) { $ value = $ parts [ $ i ] ; if ( is_array ( $ result ) && array_key_exists ( $ value , $ result ) ) { $ result = $ result [ $ value ] ; continue ; } $ result = null ; break ; } return $ result ; }
Retrieves nested data from the settings .
17,398
public function isSameValueAs ( Locale $ other ) { return $ this -> languageCode == $ other -> languageCode && $ this -> countryCode == $ other -> countryCode ; }
Compares two Locales
17,399
public function format ( $ format ) { if ( ! is_string ( $ format ) ) { throw new InvalidArgumentException ( sprintf ( 'format passed must be a string' ) ) ; } $ translateNext = false ; $ escNext = false ; $ formatted = '' ; foreach ( str_split ( $ format ) as $ char ) { if ( $ escNext ) { $ formatted .= $ char ; $ escNext = false ; continue ; } if ( $ translateNext ) { switch ( $ char ) { case 'c' : $ translated = strtolower ( $ this -> getCountryCode ( ) ) ; break ; case 'C' : $ translated = strtoupper ( $ this -> getCountryCode ( ) ) ; break ; case 'l' : $ translated = strtolower ( $ this -> getLanguageCode ( ) ) ; break ; case 'L' : $ translated = strtoupper ( $ this -> getLanguageCode ( ) ) ; break ; default : throw new InvalidArgumentException ( sprintf ( 'Unkown format' ) ) ; } $ formatted .= $ translated ; $ translateNext = false ; continue ; } if ( '\\' == $ char ) { $ escNext = true ; continue ; } elseif ( '%' == $ char ) { $ translateNext = true ; continue ; } $ formatted .= $ char ; } return $ formatted ; }
Format Locale as string