idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
11,900
public function consume ( $ queue , $ prefetchCount = null , $ prefetchSize = null , $ consumerId = null ) : Observable { return $ this -> channel ( ) -> do ( function ( Channel $ channel ) use ( $ prefetchCount , $ prefetchSize ) { $ channel -> qos ( $ prefetchSize , $ prefetchCount ) ; } ) -> flatMap ( function ( Cha...
Consume given queue at .
11,901
public function insertBatch ( string $ from , array $ dataSet , array $ options = [ ] ) { list ( $ statement , $ bindings ) = $ this -> compileInsert ( $ from , $ dataSet , $ options [ 'columns' ] ?? [ ] , true ) ; if ( isset ( $ options [ 'returnSql' ] ) ) { return [ $ statement , $ bindings ] ; } return $ this -> fet...
Run a statement for insert multi row
11,902
public function update ( string $ from , $ wheres , array $ values , array $ options = [ ] ) { list ( $ where , $ bindings ) = DBHelper :: handleConditions ( $ wheres , $ this ) ; $ options [ 'update' ] = $ this -> qn ( $ from ) ; $ options [ 'where' ] = $ where ; $ statement = $ this -> compileUpdate ( $ values , $ bi...
Run a update statement
11,903
public function authenticatedUser ( $ token = null ) { $ token = $ this -> getToken ( $ token ) ; $ user = $ this -> client -> get ( 'https://api.twitch.tv/kraken/user?oauth_token=' . $ token ) ; return $ user -> json ( ) ; }
Returns a user object .
11,904
public static function errorHandler ( $ code , $ message , $ file , $ line ) { if ( error_reporting ( ) === 0 ) { return false ; } throw new \ sb \ Exception ( $ code , $ message , $ file , $ line ) ; }
Converts errors into exceptions
11,905
public static function exceptionHandler ( $ e ) { $ message = 'Code: ' . $ e -> getCode ( ) . "\n" . 'Path: ' . \ sb \ Gateway :: $ request -> path . "\n" . 'Message: ' . $ e -> getMessage ( ) . "\n" . 'Location: ' . $ e -> getFile ( ) . "\n" . 'Line: ' . $ e -> getLine ( ) . "\n" ; if ( isset ( \ sb \ Gateway :: $ req...
Handles acceptions and turns them into strings
11,906
public static function shutdown ( ) { if ( \ is_null ( $ e = \ error_get_last ( ) ) === false ) { self :: exceptionHandler ( new \ sb \ Exception ( $ e [ 'type' ] , $ e [ 'message' ] , $ e [ 'file' ] , $ e [ 'line' ] ) ) ; } }
Shutdown function catches additional parse errors
11,907
public static function init ( $ error_reporting_level = E_ALL , $ display_errors = true , $ show_trace = true ) { \ error_reporting ( $ error_reporting_level ) ; \ ini_set ( "display_errors" , $ display_errors ? true : false ) ; self :: $ show_trace = $ show_trace ? true : false ; \ set_error_handler ( '\sb\Application...
Sets up debugger
11,908
public static function availableTypes ( ) { return [ self :: VALUE_INT , self :: VALUE_STRING , self :: VALUE_BOOL , self :: VALUE_FLOAT , self :: VALUE_DEFAULT , self :: VALUE_NON_EXISTS , self :: VALUE_EMPTY , self :: VALUE_ARRAY , ] ; }
Get Available Value Types
11,909
public static function availableDefaultValues ( ) { return [ self :: DEFAULT_NULL , self :: DEFAULT_OUT_OF_BOUNDS , self :: DEFAULT_NOT_DERIVABLE , self :: DEFAULT_NOT_GIVEN , self :: DEFAULT_NOT_ASKED , self :: DEFAULT_NOT_PERMITTED , ] ; }
Get Available Default Values
11,910
public function transform ( $ value ) { if ( $ value === null || $ value == '' ) { return null ; } if ( ! ( $ value instanceof User ) ) { throw new TransformationFailedException ( 'Expected an instance of a concrete5 user object.' ) ; } return intval ( $ value -> getUserID ( ) ) ; }
Converts a concrete5 user object to an integer .
11,911
public function help ( $ event_name , $ callback ) { if ( ! isset ( $ this -> event_helpers [ $ event_name ] ) ) { $ this -> event_helpers [ $ event_name ] = $ callback ; } }
add a helper callback to an event
11,912
public function sendContent ( SendResponseEvent $ e ) { $ response = $ e -> getResponse ( ) ; if ( ! $ response instanceof ApiProblemResponse ) { return $ this ; } $ response -> getApiProblem ( ) -> setDetailIncludesStackTrace ( $ this -> displayExceptions ( ) ) ; $ request = $ this -> getMvcEvent ( ) -> getRequest ( )...
Send the response content
11,913
public function sendHeaders ( SendResponseEvent $ e ) { $ response = $ e -> getResponse ( ) ; if ( ! $ response instanceof ApiProblemResponse ) { return $ this ; } $ request = $ this -> getMvcEvent ( ) -> getRequest ( ) ; $ accept = $ request -> getHeader ( 'Accept' ) ; if ( $ accept instanceof Accept && $ accept -> ha...
Send HTTP response headers
11,914
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { $ signature = ( $ this -> signature ) ( $ request ) ; if ( ! is_array ( $ signature ) ) { throw new OwnershipSignatureTypeException ( $ signature ) ; } $ metadata = $ _SESSION [ self :: METADATA_KEY ] ...
Build a signature and compare it to the ownership metadata stored in session . Invalidate the session when any key does not match . Process the request and save the current signature in session .
11,915
private function compare ( array $ signature , array $ metadata ) : bool { foreach ( $ signature as $ key => $ v1 ) { $ v2 = $ metadata [ $ key ] ?? null ; if ( ! is_null ( $ v2 ) && $ v1 !== $ v2 ) return false ; } return true ; }
Return whether all keys of the given signature match the given metadata .
11,916
public function configureLogger ( $ logger , $ level , $ logPath = null ) { $ monolog = $ logger ; switch ( $ level ) { case 'emergency' : case 'emerg' : $ level = Logger :: EMERGENCY ; break ; case 'alert' : $ level = Logger :: ALERT ; break ; case 'critical' : case 'crit' : $ level = Logger :: CRITICAL ; break ; case...
Removes all logging handlers and replaces them with handlers that can write to the given logPath and level .
11,917
protected function addLogging ( ) { $ this -> register ( new MonologServiceProvider ( ) , array ( 'monolog.name' => 'phpDocumentor' , 'monolog.logfile' => sys_get_temp_dir ( ) . '/phpdoc.log' , 'monolog.debugfile' => sys_get_temp_dir ( ) . '/phpdoc.debug.log' , 'monolog.level' => Logger :: INFO , ) ) ; $ app = $ this ;...
Adds a logging provider to the container of phpDocumentor .
11,918
public static function generateSuffixedIdentName ( array $ identNames , $ suffix ) { $ ident = implode ( "_" , $ identNames ) . "_" . $ suffix ; $ i = 0 ; $ last = - 1 ; while ( strlen ( $ ident ) > self :: IDENTIFIER_MAX_LENGTH ) { if ( strlen ( $ identNames [ $ i ] ) > 1 || $ last == $ i ) { $ identNames [ $ i ] = su...
Generate single identifier name for constraints for example obeying oracle 30 chars ident restriction .
11,919
protected function createInstallOneOfRule ( array $ packages , $ reason , $ job ) { $ literals = array ( ) ; foreach ( $ packages as $ package ) { $ literals [ ] = $ package -> id ; } return new Rule ( $ literals , $ reason , $ job [ 'packageName' ] , $ job ) ; }
Creates a rule to install at least one of a set of packages
11,920
protected function createRemoveRule ( PackageInterface $ package , $ reason , $ job ) { return new Rule ( array ( - $ package -> id ) , $ reason , $ job [ 'packageName' ] , $ job ) ; }
Creates a rule to remove a package
11,921
protected function createConflictRule ( PackageInterface $ issuer , PackageInterface $ provider , $ reason , $ reasonData = null ) { if ( $ issuer === $ provider ) { return null ; } return new Rule ( array ( - $ issuer -> id , - $ provider -> id ) , $ reason , $ reasonData ) ; }
Creates a rule for two conflicting packages
11,922
private function addRule ( $ type , Rule $ newRule = null ) { if ( ! $ newRule || $ this -> rules -> containsEqual ( $ newRule ) ) { return ; } $ this -> rules -> add ( $ newRule , $ type ) ; }
Adds a rule unless it duplicates an existing one of any type
11,923
public function parse ( ) { if ( ! is_string ( $ this -> data ) ) { throw new \ RuntimeException ( 'The given data is no valid string' ) ; } libxml_use_internal_errors ( true ) ; $ xml = simplexml_load_string ( $ this -> data ) ; if ( $ xml === false ) { throw new \ RuntimeException ( 'Error during the loading of the X...
Load the configuration and return it in an easy to use config bag .
11,924
protected function build_input ( $ data , array $ fields = [ ] ) { $ input = $ this -> get_open_tag ( $ data , $ fields ) ; $ counter = 1 ; foreach ( $ this -> get_options ( ) as $ key => $ label ) { $ input .= $ this -> get_option ( $ key , $ label , $ counter , $ data , $ fields ) ; $ counter ++ ; } $ input .= $ this...
Show input labels
11,925
public function get ( $ method , array $ params , array $ options = array ( ) ) { $ this -> parseOptions ( $ options ) ; $ params = array_merge ( $ params , $ this -> apiKeys ) ; $ response = $ this -> httpAdapter -> getContent ( sprintf ( self :: API_ENDPOINT , $ this -> scheme , $ this -> outputFormat , $ method . '?...
Calls the Eventbrite API via GET
11,926
private function parseOptions ( array $ options ) { if ( isset ( $ options [ 'headers' ] ) && is_array ( $ options [ 'headers' ] ) ) { $ this -> headers = $ options [ 'headers' ] ; } if ( isset ( $ options [ 'scheme' ] ) && strtolower ( $ options [ 'scheme' ] ) === 'http' ) { $ this -> scheme = 'http' ; } if ( isset ( ...
Parser for options like scheme headers and output format .
11,927
private function responseHandler ( $ responseBody ) { if ( 'json' === $ this -> outputFormat ) { return $ this -> validateJsonResponse ( $ responseBody ) ; } return $ this -> validateXmlResponse ( $ responseBody ) ; }
Handler for validate the response body .
11,928
private function validateJsonResponse ( $ responseBody ) { $ data = json_decode ( $ responseBody ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new \ Exception ( 'Error decoding JSON.' ) ; } if ( isset ( $ data -> error ) ) { throw new \ Exception ( $ data -> error -> error_message ) ; } if ( empty ( $ data...
Parses the response content for the JSON output format
11,929
private function validateXmlResponse ( $ responseBody ) { $ data = simplexml_load_string ( $ responseBody ) ; if ( isset ( $ data -> error_type ) ) { throw new \ Exception ( $ data -> error_message ) ; } return $ responseBody ; }
Parses the response content for the XML output format
11,930
public function getTypes ( $ number ) { $ binstring = decbin ( ( int ) $ number ) ; $ types = array ( ) ; $ mlen = strlen ( $ binstring ) - 3 ; $ low = substr ( $ binstring , $ mlen , strlen ( $ binstring ) ) ; $ high = substr ( $ binstring , 0 , $ mlen ) . '0000' ; $ types [ 'wired' ] = bindec ( $ low ) ; $ types [ 'f...
Get the wired_type and field_type
11,931
public function serializeToString ( $ rec = - 1 ) { $ string = '' ; if ( $ rec > - 1 ) { $ string .= $ this -> base128 -> setValue ( $ rec << 3 | $ this -> wired_type ) ; } $ stringinner = '' ; foreach ( $ this -> fields as $ index => $ field ) { if ( is_array ( $ this -> values [ $ index ] ) && count ( $ this -> value...
Encodes a Message
11,932
protected function addArrValue ( $ index ) { $ class_name = $ this -> fields [ $ index ] ; $ real_class_name = __NAMESPACE__ . "\\" . $ class_name ; return $ this -> values [ $ index ] [ ] = new $ real_class_name ( ) ; }
Add an array value
11,933
protected function setValue ( $ index , $ value ) { if ( gettype ( $ value ) === 'object' ) { $ this -> values [ $ index ] = $ value ; } else { $ class_name = $ this -> fields [ $ index ] ; $ real_class_name = __NAMESPACE__ . "\\" . $ class_name ; $ this -> values [ $ index ] = new $ real_class_name ( ) ; $ this -> val...
Set an value
11,934
protected function saveString ( $ ch , $ string ) { $ this -> dString .= $ string ; $ content_length = strlen ( $ this -> dString ) ; return strlen ( $ string ) ; }
Helper method for send string
11,935
public function failure ( Exception $ e , Delivery $ delivery , AbstractListener $ listener ) { $ listener -> resend ( $ delivery ) ; }
Handle any exception during queued message data processing .
11,936
public function toString ( $ indent = null ) { $ helperManager = $ this -> getView ( ) -> getHelperPluginManager ( ) ; if ( $ helperManager -> has ( 'dojo' ) ) { $ dojo = $ helperManager -> get ( 'dojo' ) ; $ dojo -> initialize ( ) ; } return parent :: toString ( $ indent ) ; }
Find an initialize Dojo helper before rendering head scripts
11,937
public function addTranslations ( $ filename , $ locale = self :: DEFAULT_LOCALE , $ textDomain = self :: DEFAULT_DOMAIN ) { parent :: addTranslationFile ( self :: TRANSLATION_FILE_TYPE , $ filename , $ textDomain , $ locale ) ; $ this -> messages = array ( ) ; return $ this ; }
Adds a translation file for a specific locale or the default locale when none is provided .
11,938
public function addTranslationFolder ( $ folder , array $ domains = array ( ) ) { if ( empty ( $ domains ) ) { $ domains = array ( self :: DEFAULT_DOMAIN ) ; } foreach ( $ domains as $ domain ) { $ this -> addTranslationsUsingPattern ( $ folder , $ domain ) ; } return $ this ; }
Adds a folder with files containing translation sources .
11,939
public function addTranslationsUsingPattern ( $ baseDir , $ textDomain = self :: DEFAULT_DOMAIN , $ pattern = self :: DEFAULT_PATTERN ) { if ( $ textDomain !== self :: DEFAULT_DOMAIN && $ pattern === self :: DEFAULT_PATTERN ) { $ pattern = $ textDomain . '.' . $ pattern ; } parent :: addTranslationFilePattern ( self ::...
Adds a series of translation files given a pattern .
11,940
public function translate ( $ message , $ textDomain = self :: DEFAULT_DOMAIN , $ locale = null ) { return parent :: translate ( $ message , $ textDomain , $ locale ) ; }
Attempts to translate the given message or code into the provided locale .
11,941
private function insertUpdate ( $ parentUpdate , $ update ) { $ el = $ update instanceof ElementDependentLayoutUpdateInterface ? $ update -> getElement ( ) : 'root' ; $ parentUpdateIndex = array_search ( $ parentUpdate , $ this -> updates [ $ el ] ) ; $ this -> updates [ $ el ] = array_merge ( array_slice ( $ this -> u...
Insert import update right after its parent update
11,942
function dispatch ( $ uri ) { $ old_handler = set_error_handler ( array ( $ this , 'error_handler' ) , 5888 ) ; ob_start ( ) ; $ level = ob_get_level ( ) ; $ this -> map_uri_to_response ( $ this -> clean_request_uri ( ( string ) $ uri ) ) -> output ( ) ; while ( ob_get_level ( ) >= $ level ) { ob_end_flush ( ) ; } if (...
Maps a string to a response which is then rendered .
11,943
function perform ( $ unconsumed ) { list ( $ action , $ args , $ format ) = $ this -> extract_action_and_args ( $ unconsumed ) ; $ this -> format = isset ( $ format ) ? $ format : 'html' ; $ before_filter_result = $ this -> before_filter ( $ action , $ args ) ; if ( ! ( FALSE === $ before_filter_result || $ this -> per...
This method extracts an action string and further arguments from it s parameter . The action string is mapped to a method being called afterwards using the said arguments . That method is called and a response object is generated populated and sent back to the dispatcher .
11,944
function extract_action_and_args ( $ string ) { if ( '' === $ string ) { return array ( 'index' , array ( ) , NULL ) ; } $ format = NULL ; if ( preg_match ( '/^(.*[^\/.])\.(\w+)$/' , $ string , $ matches ) ) { list ( $ _ , $ string , $ format ) = $ matches ; } $ args = explode ( '/' , $ string ) ; $ action = array_shif...
Extracts action and args from a string .
11,945
function url_for ( $ to ) { $ args = func_get_args ( ) ; $ args = array_map ( 'urlencode' , $ args ) ; $ args [ 0 ] = $ to ; return $ this -> dispatcher -> trails_uri . '/' . join ( '/' , $ args ) ; }
Returns a URL to a specified route to your Trails application .
11,946
public function getContainer ( ) { $ mutex = new Mutex ( $ this -> file . '.lock' , true ) ; $ ret = $ mutex -> run ( function ( ) { if ( $ this -> needsRecompile ( ) ) { file_put_contents ( $ this -> file , $ this -> compileContainerCode ( ) ) ; } return include $ this -> file ; } ) ; if ( ! ( $ ret instanceof Contain...
Writes the code to a temporary file and returns the resulting Container object .
11,947
protected function needsRecompile ( ) { clearstatcache ( ) ; return ! is_file ( $ this -> file ) || ( ( ! empty ( $ this -> configTree [ 'z' ] [ 'sources' ] ) && max ( array_map ( 'filemtime' , $ this -> configTree [ 'z' ] [ 'sources' ] ) ) >= filemtime ( $ this -> file ) ) ) ; }
Crude check for whether a recompile is needed .
11,948
public function compileContainerCode ( ) { $ builder = new ContainerBuilder ( $ this -> configTree ) ; foreach ( $ this -> plugins as $ name => $ plugin ) { $ plugin -> setContainerBuilder ( $ builder ) ; } $ containerNode = $ builder -> build ( ) ; $ buffer = new Buffer ( ) ; $ buffer -> write ( '<?php' ) -> eol ( ) ;...
Returns the code for initializing the container .
11,949
public static function instances ( ) { $ all = [ ] ; foreach ( static :: getNames ( ) as $ name => $ val ) { $ all [ ] = new static ( $ name , $ val ) ; } return $ all ; }
Gets all enums
11,950
public static function nameOf ( $ value ) { $ values = static :: getValues ( ) ; return isset ( $ values [ $ value ] ) ? $ values [ $ value ] : null ; }
Gets the name for the enum value
11,951
public static function valueOf ( $ name ) { $ names = static :: getNames ( ) ; return isset ( $ names [ $ name ] ) ? $ names [ $ name ] : null ; }
Gets the enum value for the name
11,952
public static function fromName ( $ name ) { $ names = static :: getNames ( ) ; if ( array_key_exists ( $ name , $ names ) ) { return new static ( $ name , $ names [ $ name ] ) ; } throw new \ InvalidArgumentException ( "No enum constant '$name' in class " . get_called_class ( ) ) ; }
Gets the enum instance for the name
11,953
public static function fromValue ( $ value ) { $ values = static :: getValues ( ) ; if ( array_key_exists ( $ value , $ values ) ) { return new static ( $ values [ $ value ] , $ value ) ; } throw new \ InvalidArgumentException ( "No enum constant value '$value' class " . get_called_class ( ) ) ; }
Gets the enum instance for the value
11,954
public function s2o ( $ sql , $ params = null , $ class_name = '' ) { if ( is_array ( $ params ) || is_object ( $ params ) ) { $ param = is_array ( $ params ) ? $ params : self :: paramify ( $ params ) ; $ stmt = $ this -> prepare ( $ sql ) ; $ result = $ stmt -> execute ( $ params ) ; if ( ! $ result ) { return Array ...
Turn a sql query into an array of objects representing each row returned
11,955
public static function paramify ( $ data , $ omit = Array ( ) ) { $ params = Array ( ) ; if ( is_object ( $ data ) ) { $ data = get_object_vars ( $ data ) ; } if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ val ) { if ( ! in_array ( $ key , $ omit ) ) { $ params [ ':' . $ key ] = $ val ; } } } return $ para...
Converts an array into a bound params hash
11,956
public function prepare ( $ sql , $ driver_options = array ( ) ) { $ md5 = md5 ( $ sql ) ; if ( isset ( $ this -> prepared_sql [ $ md5 ] ) ) { return $ this -> prepared_sql [ $ md5 ] ; } $ stmt = parent :: prepare ( $ sql , $ driver_options ) ; $ this -> prepared_sql [ $ md5 ] = $ stmt ; return $ stmt ; }
Used to prepare and store sql statements for value binding
11,957
protected function printLicenses ( CompletePackageInterface $ package ) { $ spdxLicense = new SpdxLicense ; $ licenses = $ package -> getLicense ( ) ; foreach ( $ licenses as $ licenseId ) { $ license = $ spdxLicense -> getLicenseByIdentifier ( $ licenseId ) ; if ( ! $ license ) { $ out = $ licenseId ; } else { if ( $ ...
Prints the licenses of a package with metadata
11,958
protected function filterElements ( Collection $ collection , AdminMenu $ parent = null ) { $ children = $ collection -> filter ( function ( AdminMenu $ menuItem ) use ( $ parent ) { return $ menuItem -> getParent ( ) === $ parent ; } ) ; return $ children ; }
Filters the collection and returns only children elements for given parent element
11,959
public function getCompiler ( ) { if ( ! $ this -> compiler instanceof AbstractCompiler ) { if ( null === $ this -> compiler ) { throw new \ Exception ( 'Compiler not set' ) ; } $ compiler = $ this -> getView ( ) -> getHelperPluginManager ( ) -> getServiceLocator ( ) -> get ( $ this -> compiler ) ; if ( ! $ compiler in...
Get compiler instance
11,960
protected function initializeResolver ( ) { $ extensions = $ this -> getCompiler ( ) -> getExtensions ( ) ; $ resolver = $ this -> resolver = new AggregateResolver ( ) ; $ stack = array ( $ this -> getView ( ) -> resolver ( ) ) ; while ( $ source = array_shift ( $ stack ) ) { if ( $ source instanceof AggregateResolver ...
Initializes Resolver to find files by mimicking the default template resolver and using compiler extensions .
11,961
public function getGuards ( ) : array { if ( $ this -> guards ) { return $ this -> guards ; } if ( empty ( $ this -> guardsConfig ) ) { return [ ] ; } $ this -> guards = [ ] ; foreach ( $ this -> guardsConfig as $ guardConfig ) { $ this -> guards [ ] = $ this -> getGuardFactory ( ) -> create ( $ guardConfig ) ; } $ thi...
Gets the cached guard list or creates it from the config
11,962
protected function sortGuardsByPriority ( ) { usort ( $ this -> guards , function ( GuardInterface $ a , GuardInterface $ b ) { return $ b -> getPriority ( ) - $ a -> getPriority ( ) ; } ) ; }
Sort the guards list internally
11,963
public function getFilters ( ) { $ parser = \ Parsedown :: instance ( ) ; $ translator = $ this -> translator ; $ routeRenderer = $ this -> routeRenderer ; return array ( 'markdown' => new \ Twig_SimpleFilter ( 'markdown' , function ( $ value ) use ( $ parser ) { return $ parser -> text ( $ value ) ; } ) , 'trans' => n...
Returns a list of all filters that are exposed by this extension .
11,964
public function virtualToScalable ( $ event ) { if ( ( $ this -> scalableAttributeName ( ) !== null ) && ( $ this -> virtualAttributesNames ( ) !== null ) ) { $ data = [ ] ; foreach ( $ this -> virtualAttributesNames ( ) as $ name ) { if ( ! empty ( $ this -> owner -> { $ name } ) ) { $ data [ $ name ] = $ this -> owne...
Converts configured attributes before saving them to database
11,965
public function scalableToVirtual ( $ event = null ) { if ( ( $ this -> scalableAttributeName ( ) !== null ) && ( $ this -> virtualAttributesNames ( ) !== null ) ) { $ virtualAttributesConf = [ ] ; foreach ( $ this -> virtualAttributesNames ( ) as $ name ) { $ virtualAttributesConf [ $ name ] = '' ; } $ virtualAttribut...
Checks if the defined attributes are unserializeable and unserializes their values
11,966
public function convert ( $ data ) { if ( empty ( $ data ) || ( $ out = @ serialize ( $ data ) ) === false ) return null ; return $ out ; }
Converts some input to a serialized string
11,967
public function unConvert ( $ data ) { if ( empty ( $ data ) || ! is_string ( $ data ) || ( $ out = @ unserialize ( $ data ) ) === false ) return null ; if ( ! is_array ( $ out ) || empty ( $ out ) ) return null ; return $ out ; }
Unconverts a serialized string into an array
11,968
public function scalableAttributeName ( ) { if ( $ this -> _scalableAttribute !== null ) return $ this -> _scalableAttribute ; if ( in_array ( ( string ) $ this -> scalableAttribute , $ this -> objAttributesNames ( ) ) ) return $ this -> _scalableAttribute = $ this -> scalableAttribute ; return null ; }
Verifies the configured scalable attribute
11,969
public function virtualAttributesNames ( ) { if ( ! empty ( $ this -> _virtualAttributes ) ) return $ this -> _virtualAttributes ; if ( ! is_array ( $ this -> virtualAttributes ) || empty ( $ this -> virtualAttributes ) ) return null ; $ attributes = [ ] ; foreach ( $ this -> virtualAttributes as $ a ) { if ( ! in_arra...
Verifies the configured virtual attributes
11,970
public function validateId ( $ attribute , $ params ) { foreach ( Yii :: $ app -> user -> getLoginPriority ( ) as $ item ) { if ( $ item :: validate ( $ this -> $ attribute ) ) { return ; } } $ this -> addError ( $ attribute , Yii :: t ( 'user' , 'Incorrect ID.' ) ) ; }
Validates the ID .
11,971
public static function increment ( string $ str , int $ first = 1 , string $ separator = '_' ) : string { preg_match ( '/(.+)' . $ separator . '([0-9]+)$/' , $ str , $ match ) ; return isset ( $ match [ 2 ] ) ? $ match [ 1 ] . $ separator . ( $ match [ 2 ] + 1 ) : $ str . $ separator . $ first ; }
Add s _1 to a string or increment the ending number to allow _2 _3 etc
11,972
public static function safeString ( string $ str , string $ delimiter = '-' , bool $ lowercase = false ) : string { $ str = filter_var ( $ str , FILTER_SANITIZE_STRING ) ; $ str = html_entity_decode ( $ str , ENT_QUOTES , 'UTF-8' ) ; $ reserved_characters = array ( '/' , '?' , ':' , '@' , '#' , '[' , ']' , '!' , '$' , ...
Create safe string . Use to create safe usernames or filenames .
11,973
protected function adjustCaseInsensitive ( & $ value , & $ parameters ) { $ parameterAmount = count ( $ parameters ) ; if ( $ parameterAmount == 1 || $ parameterAmount > 1 && $ parameters [ 1 ] ) { $ parameters [ 0 ] = strtolower ( $ parameters [ 0 ] ) ; $ value = strtolower ( $ value ) ; } }
Adjusts value and parameters to be case insensitive if the second parameter says so or is not given .
11,974
public function get ( ConnectionContract $ connection , MailFactoryContract $ factory ) { $ uids = $ connection -> search ( $ this -> parseSearch ( ) ) ; $ stream = $ connection -> getStream ( ) ; $ max = $ this -> limit > 0 ? $ this -> limit : self :: $ max ; $ uids = array_slice ( $ uids , 0 , $ max ) ; return array_...
Execute search query on connection and put results into Mail wrappers using factory
11,975
public function where ( $ flag , $ value = null ) { if ( ! in_array ( strtolower ( $ flag ) , static :: $ searchCriteria ) ) { throw new InvalidArgumentException ( "Invalid where criteria '{$flag}'" ) ; } $ this -> where [ $ flag ] = $ value ; return $ this ; }
Set where condition .
11,976
public function order ( $ orderFlag , $ dir = 'desc' ) { if ( ! in_array ( $ orderFlag , static :: $ orderCriteria ) ) { throw new InvalidArgumentException ( "Invalid order criteria '{$orderFlag}'" ) ; } $ this -> order = $ orderFlag ; $ this -> orderDir = strtolower ( $ dir ) === 'asc' ? 0 : 1 ; return $ this ; }
Set sorting order .
11,977
protected function parseSearch ( ) { return implode ( ' ' , array_map ( function ( $ key , $ val ) { if ( is_null ( $ val ) ) { return strtoupper ( $ key ) ; } return sprintf ( '%s %s' , strtoupper ( $ key ) , $ val ) ; } , array_keys ( $ this -> where ) , array_values ( $ this -> where ) ) ) ; }
Parse the where conditions for imap_search
11,978
protected function toScalar ( $ value ) { if ( is_scalar ( $ value ) ) { return $ value ; } elseif ( null === $ value ) { return 'NULL' ; } else { if ( is_object ( $ value ) ) { if ( is_callable ( [ $ value , '__toString' ] ) ) { return ( string ) $ value ; } elseif ( $ value instanceof \ DateTimeInterface ) { return $...
Attempt to convert non - scalar values .
11,979
public function prePersist ( EventArgs $ args ) { $ em = $ args -> getEntityManager ( ) ; $ object = $ args -> getObject ( ) ; $ class = get_class ( $ object ) ; $ meta = $ em -> getClassMetadata ( $ class ) ; $ reflectionClass = $ meta -> getReflectionClass ( ) ; if ( ! $ reflectionClass || ! $ this -> hasTrait ( $ re...
Compute sortRank for entities that are created .
11,980
public function getGenericResources ( $ limit = 10 , $ mode = AbstractQuery :: HYDRATE_OBJECT ) { $ builder = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) ; $ builder -> select ( 'e' ) -> from ( $ this -> getEntity ( ) , 'e' ) -> where ( 'e.isGeneric = 1' ) -> setMaxResults ( $ limit ) ; $ query = LocaleAwa...
List Generic Resources
11,981
private function handleException ( \ Throwable $ t , Request $ request ) { if ( $ this -> log !== null ) { $ this -> log -> error ( 'Exception thrown inside a controller.' , array ( 'exception' => $ t , ) ) ; } else { error_log ( $ t -> getMessage ( ) . ' - ' . $ t -> getTraceAsString ( ) ) ; } $ response = SplashUtils...
Actually handle the exception .
11,982
public function cerrarMesa ( $ mesa_id , $ imprimir_ticket = true ) { $ this -> Mesa -> id = $ mesa_id ; if ( ! $ this -> Mesa -> cerrar_mesa ( ) ) { if ( ! $ this -> request -> is ( 'ajax' ) ) { $ this -> setFlash ( 'Error al cerrar la mesa' , 'flash_error' ) ; } } if ( ! $ this -> request -> is ( 'ajax' ) ) { $ this ...
Cierra la mesa calculando el total y si se lo indica imprime el ticket fiscal .
11,983
public function render ( $ mode , $ node ) { return ( $ mode > 0 || $ node -> hasProperty ( 'renderBox' ) == false || $ node -> getProperty ( 'renderBox' ) === null || $ node -> getProperty ( 'renderBox' ) === true ) ? true : false ; }
Decide if box should be rendered or not based on renderMode and node properties
11,984
public function transform ( $ role ) { $ role = $ this -> entityToArray ( Role :: class , $ role ) ; return [ 'id' => ( int ) $ role [ 'id' ] , 'name' => $ role [ 'name' ] , 'createdAt' => $ role [ 'created_at' ] , 'updatedAt' => $ role [ 'updated_at' ] ] ; }
Transforms role entity
11,985
public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { $ this -> _args [ count ( $ this -> _args ) ] = $ value ; } else { if ( is_int ( $ offset ) ) { $ this -> _args [ $ offset ] = $ value ; } else { throw new \ Exception ( 'Cannot set offset \'' . $ offset . '\' of IndexedArray.' ) ; } } }
Override the offsetSet function to enforce integral keys only .
11,986
public function offsetGet ( $ offset ) { if ( isset ( $ this -> _args [ $ offset ] ) ) { if ( is_array ( $ this -> _args [ $ offset ] ) ) { return new AssociativeArray ( $ this -> _args [ $ offset ] ) ; } else { return $ this -> _args [ $ offset ] ; } } else { throw new \ Exception ( 'Undefined offset \'' . $ offset . ...
Override the offsetGet function to throw an undefined offset error when a key is not found .
11,987
private function isPrefixedKey ( $ key ) { if ( strlen ( $ key ) > 1 ) { if ( substr ( $ key , 0 , 1 ) == '_' ) { try { intval ( substr ( $ key , 1 , strlen ( $ key ) - 1 ) ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } } }
Check if a string is in the proper format to be a prefixed integral array key .
11,988
public function getPlatformRequirements ( $ withDevReqs = false ) { $ lockData = $ this -> getLockData ( ) ; $ versionParser = new VersionParser ( ) ; $ requirements = array ( ) ; if ( ! empty ( $ lockData [ 'platform' ] ) ) { $ requirements = $ versionParser -> parseLinks ( '__ROOT__' , '1.0.0' , 'requires' , isset ( ...
Returns the platform requirements stored in the lock file
11,989
public function setLockData ( array $ packages , $ devPackages , array $ platformReqs , $ platformDevReqs , array $ aliases , $ minimumStability , array $ stabilityFlags , $ preferStable , $ preferLowest , array $ platformOverrides ) { $ lock = array ( '_readme' => array ( 'This file locks the dependencies of your proj...
Locks provided data into lockfile .
11,990
protected function _initResource ( $ config ) { if ( ! empty ( $ config [ 'data' ] ) && ! empty ( $ config [ 'filename' ] ) ) { throw new InvalidArgumentException ( "The `'data'` or `'filename'` option must be defined." ) ; } if ( $ config [ 'filename' ] ) { $ this -> _filename = $ config [ 'filename' ] ; if ( $ this -...
Init the stream resource .
11,991
public function length ( ) { if ( $ this -> _limit !== null ) { return $ this -> _limit ; } if ( $ this -> _length !== null ) { return $ this -> _length ; } if ( $ this -> isSeekable ( ) ) { $ old = $ this -> tell ( ) ; $ begin = $ this -> rewind ( ) ; $ end = $ this -> end ( ) ; $ this -> seek ( $ old ) ; return $ end...
Get the stream range length .
11,992
public function meta ( $ key = null ) { if ( $ this -> _resource === null && $ this -> _filename ) { $ this -> _resource = fopen ( $ this -> _filename , $ this -> _mode ) ; } if ( ! $ this -> valid ( ) ) { throw new RuntimeException ( 'Invalid resource.' ) ; } $ meta = stream_get_meta_data ( $ this -> _resource ) ; if ...
Get stream meta data .
11,993
protected function _ensureReadable ( $ bytePerByte = true ) { if ( ! $ this -> valid ( ) ) { throw new RuntimeException ( 'Cannot read from a closed stream.' ) ; } if ( ! $ this -> isReadable ( ) ) { $ mode = $ this -> meta ( 'mode' ) ; throw new RuntimeException ( "Cannot read on a non-readable stream (mode is `'{$mod...
Throw an exception if a stream is not readable .
11,994
protected function _ensureWritable ( ) { if ( ! $ this -> valid ( ) ) { throw new RuntimeException ( 'Cannot write on a closed stream.' ) ; } if ( ! $ this -> isWritable ( ) ) { $ mode = $ this -> meta ( 'mode' ) ; throw new RuntimeException ( "Cannot write on a non-writable stream (mode is `'{$mode}'`)." ) ; } }
Throw an exception if a stream is not writable .
11,995
protected function _bufferSize ( $ length ) { if ( $ this -> _limit !== null ) { $ position = $ this -> tell ( ) ; $ max = $ this -> _start + $ this -> _limit ; $ length = $ max - $ position ; } if ( $ length === null ) { $ length = $ this -> _bufferSize ; } return $ length ; }
Determine the buffer size to read .
11,996
public function pipe ( $ stream ) { $ offset = $ stream -> tell ( ) ; $ result = stream_copy_to_stream ( $ this -> resource ( ) , $ stream -> resource ( ) ) ; if ( $ stream -> isSeekable ( ) ) { $ stream -> seek ( $ offset ) ; } return $ result ; }
Read the content of this stream and write it to another stream .
11,997
public function seek ( $ offset , $ whence = SEEK_SET ) { if ( $ this -> _filename === 'php://input' && $ this -> eof ( ) && ! $ offset && $ whence === SEEK_SET ) { $ this -> close ( ) ; $ this -> _resource = fopen ( $ this -> _filename , 'r' ) ; } $ this -> _ensureSeekable ( ) ; fseek ( $ this -> _resource , $ offset ...
Seek on the stream .
11,998
public function valid ( ) { if ( $ this -> _resource === null && $ this -> _filename ) { $ this -> _resource = fopen ( $ this -> _filename , $ this -> _mode ) ; } return ! ! $ this -> _resource && is_resource ( $ this -> _resource ) ; }
Check if the stream is valid .
11,999
public static function getMime ( $ stream , $ mime ) { if ( is_string ( $ mime ) ) { return $ mime ; } if ( ! $ mime || ! $ stream -> isSeekable ( ) || ! $ stream -> isReadable ( ) ) { return ; } $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ old = $ stream -> tell ( ) ; $ stream -> rewind ( ) ; $ end = $ stream -> en...
Mime detector . Concat the first 1024 bytes + the last 4 bytes of readable & seekable streams to detext the mime info .