idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
17,000 | public function getAllValuesNode ( Node $ node = null , $ property ) { $ allValues = $ this -> getAllValues ( $ node , $ property ) ; $ output = [ ] ; foreach ( $ allValues as $ a ) if ( is_a ( $ a , 'ML\JsonLD\Node' ) ) $ output [ ] = $ a ; return $ output ; } | Reads all values from a node and returns them as a Node array . Returns only nodes literal values are skipped . |
17,001 | public static function append_config ( array $ array ) : array { $ start = 9999 ; foreach ( $ array as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ start ++ ; $ array [ $ start ] = Arr :: pull ( $ array , $ key ) ; } } return $ array ; } | Assign high numeric IDs to a config item to force appending . |
17,002 | public static function class_uses_recursive ( $ class ) { if ( \ is_object ( $ class ) ) { $ class = \ get_class ( $ class ) ; } $ results = [ ] ; foreach ( array_reverse ( class_parents ( $ class ) ) + [ $ class => $ class ] as $ class ) { $ results += self :: trait_uses_recursive ( $ class ) ; } return array_unique (... | Returns all traits used by a class its parent classes and trait of their traits . |
17,003 | public static function data_fill ( & $ target , $ key , $ value ) { return self :: data_set ( $ target , $ key , $ value , false ) ; } | Fill in data where it s missing . |
17,004 | public static function data_set ( & $ target , $ key , $ value , $ overwrite = true ) { $ segments = \ is_array ( $ key ) ? $ key : explode ( '.' , $ key ) ; if ( ( $ segment = array_shift ( $ segments ) ) === '*' ) { if ( ! Arr :: accessible ( $ target ) ) { $ target = [ ] ; } if ( $ segments ) { foreach ( $ target as... | Set an item on an array or object using dot notation . |
17,005 | public static function object_get ( $ object , $ key , $ default = null ) { if ( \ is_null ( $ key ) || trim ( $ key ) === '' ) { return $ object ; } foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! \ is_object ( $ object ) || ! isset ( $ object -> { $ segment } ) ) { return self :: value ( $ default ) ; } $ o... | Get an item from an object using dot notation . |
17,006 | public static function preg_replace_array ( $ pattern , array $ replacements , $ subject ) { return preg_replace_callback ( $ pattern , function ( ) use ( & $ replacements ) { foreach ( $ replacements as $ key => $ value ) { return array_shift ( $ replacements ) ; } } , $ subject ) ; } | Replace a given pattern with each value in the array in sequentially . |
17,007 | public static function retry ( $ times , callable $ callback , $ sleep = 0 ) { $ times -- ; beginning : try { return $ callback ( ) ; } catch ( \ Exception $ e ) { if ( ! $ times ) { throw $ e ; } $ times -- ; if ( $ sleep ) { usleep ( $ sleep * 1000 ) ; } goto beginning ; } } | Retry an operation a given number of times . |
17,008 | public static function throw_if ( $ condition , $ exception , ... $ parameters ) { if ( $ condition ) { throw ( \ is_string ( $ exception ) ? new $ exception ( ... $ parameters ) : $ exception ) ; } return $ condition ; } | Throw the given exception if the given condition is true . |
17,009 | public static function throw_unless ( $ condition , $ exception , ... $ parameters ) { if ( ! $ condition ) { throw ( \ is_string ( $ exception ) ? new $ exception ( ... $ parameters ) : $ exception ) ; } return $ condition ; } | Throw the given exception unless the given condition is true . |
17,010 | public static function transform ( $ value , callable $ callback , $ default = null ) { if ( self :: filled ( $ value ) ) { return $ callback ( $ value ) ; } if ( \ is_callable ( $ default ) ) { return $ default ( $ value ) ; } return $ default ; } | Transform the given value if it is present . |
17,011 | public static function getMostFrequentValues ( array $ data , $ mostFrequentQuantity = NULL , $ allocationPeriod = NULL ) { $ mostFrequentValues = [ ] ; $ allocatedData = self :: allocateInfo ( $ data , $ allocationPeriod ) ; usort ( $ allocatedData , function ( $ a , $ b ) { if ( $ a -> getValueQuantity ( ) === $ b ->... | Allow to sort array with SortData elements . |
17,012 | protected function renderExtraRow ( $ model , $ key , $ index , $ totals ) { if ( $ this -> extraRowValue instanceof Closure ) { $ content = call_user_func ( $ this -> extraRowValue , $ model , $ index , $ totals ) ; } else { $ values = [ ] ; foreach ( $ this -> extraRowColumns as $ name ) { $ values [ ] = ArrayHelper ... | Renders extra row when required |
17,013 | protected function isGroupEdge ( $ name , $ row ) { $ result = array ( ) ; foreach ( $ this -> _groups [ $ name ] as $ column ) { if ( $ column [ 'start' ] == $ row ) { $ result [ 'start' ] = $ row ; $ result [ 'group' ] = $ column ; } if ( $ column [ 'end' ] == $ row ) { $ result [ 'end' ] = $ row ; $ result [ 'group'... | Is current row start or end of group in particular column |
17,014 | protected function getExtraRowTotals ( $ model , $ index , $ totals ) { return $ this -> extraRowTotalsValue instanceof Closure ? call_user_func ( $ this -> extraRowTotalsValue , $ model , $ index , $ totals ) : [ ] ; } | If there is a Closure will return the newly calculated totals on the Closure according to the code specified by the user . |
17,015 | protected function getRowValues ( $ columns , $ model , $ index = 0 ) { $ values = [ ] ; $ keys = $ this -> dataProvider -> getKeys ( ) ; foreach ( $ columns as $ column ) { if ( $ column instanceof DataColumn ) { $ values [ $ column -> attribute ] = $ this -> getColumnDataCellContent ( $ column , $ model , $ keys [ $ ... | Returns the row values of the column |
17,016 | protected function getColumnDataCellContent ( $ column , $ model , $ key , $ index ) { if ( $ column -> content === null ) { return $ this -> formatter -> format ( $ this -> getColumnDataCellValue ( $ column , $ model , $ key , $ index ) , $ column -> format ) ; } else { if ( $ column -> content !== null ) { return cal... | Returns the column data cell content |
17,017 | protected function getColumnDataCellValue ( $ column , $ model , $ key , $ index ) { if ( $ column -> value !== null ) { if ( is_string ( $ column -> value ) ) { return ArrayHelper :: getValue ( $ model , $ column -> value ) ; } else { return call_user_func ( $ column -> value , $ model , $ index , $ column ) ; } } els... | Returns the column data cell value |
17,018 | public function overrideRouteTokens ( $ name , & $ tokens ) { $ menu = $ this -> repository -> findByViewRoute ( $ name ) ; if ( isset ( $ menu ) ) { $ key = array_search ( 'text' , array_column ( $ tokens , 0 ) ) ; array_splice ( $ tokens [ $ key ] , - 1 , 1 , '/' . $ menu -> getPath ( ) ) ; return true ; } return nul... | does overwrite the route tokens does return true on success or false if wrong route . |
17,019 | protected function template ( ) { $ reflector = new \ ReflectionClass ( get_class ( $ this ) ) ; $ classname = $ reflector -> getName ( ) ; $ template = preg_replace ( '/(Application|Synapse)\\\View\\\/' , '' , $ classname ) ; $ template = str_replace ( '\\' , '/' , $ template ) ; return $ template ; } | Return the corresponding template file name for this class minus file extension |
17,020 | public function compareTo ( $ obj ) { if ( ! \ is_a ( $ obj , \ get_called_class ( ) ) ) { throw new \ RuntimeException ( '$obj is not a comparable instance' ) ; } if ( \ is_int ( $ this -> _Value ) && \ is_int ( $ obj -> _Value ) ) { return Number :: compare ( $ this -> _Value , $ obj -> _Value ) ; } else if ( \ is_st... | Checks whether this enum s interval value matches another |
17,021 | public static function fromName ( $ str ) { $ strName = \ strtoupper ( \ trim ( $ str ) ) ; foreach ( static :: getConstants ( ) as $ name => $ value ) { if ( $ strName === \ strtoupper ( $ name ) ) { return new static ( $ value ) ; } } return null ; } | Creates a new enum from the case - insensitive name of a given constant |
17,022 | public function getName ( ) { foreach ( static :: getConstants ( ) as $ name => $ value ) { if ( $ this -> _Value === $ value ) { return $ name ; } } return null ; } | Returns the name of the constant which matches the enum value |
17,023 | public function query ( $ params = array ( ) , $ operator = "OR" ) { $ page = intval ( @ $ params [ 'page' ] ) ; $ size = intval ( @ $ params [ 'size' ] ) ; $ sort = @ $ params [ 'sort' ] ; unset ( $ params [ 'page' ] ) ; unset ( $ params [ 'size' ] ) ; unset ( $ params [ 'sort' ] ) ; if ( ! $ size ) $ size = 20 ; $ co... | Queries the Auth table |
17,024 | public function get ( $ username ) { if ( is_numeric ( $ username ) ) { $ key = 'id' ; } else { $ key = 'username' ; } $ query = sprintf ( self :: SELECT_ALL , $ this -> params [ 'table' ] , $ this -> params [ $ key ] , $ this -> pdo -> quote ( $ username ) ) ; $ stmt = $ this -> pdo -> query ( $ query ) ; if ( ! $ stm... | Retrieves a user from the database |
17,025 | public function & user ( $ user = null ) { if ( $ user ) { $ _SESSION [ $ this -> params [ 'session_key' ] ] = $ user ; } else { if ( ! $ this -> check ( ) ) { throw new UserException ( 'Not logged in' , 403 ) ; } } return $ _SESSION [ $ this -> params [ 'session_key' ] ] ; } | Returns the current logged in user or sets the current login data |
17,026 | public function update ( $ username , array $ data ) { $ cond = array ( ) ; unset ( $ data [ $ this -> params [ 'id' ] ] ) ; unset ( $ data [ $ this -> params [ 'password' ] ] ) ; if ( $ this -> params [ 'token' ] ) { unset ( $ data [ $ this -> params [ 'token' ] ] ) ; } if ( $ this -> params [ 'created' ] ) { unset ( ... | Update arbitrary user data |
17,027 | public function update_token ( $ username ) { $ token = self :: hash ( ) ; $ query = sprintf ( self :: UPDATE_VALUE , $ this -> params [ 'table' ] , $ this -> params [ 'token' ] , $ this -> pdo -> quote ( $ token ) , $ this -> params [ 'username' ] , $ this -> pdo -> quote ( $ username ) ) ; $ stmt = $ this -> pdo -> q... | Generates a new token for the user and update the database |
17,028 | public function & buildArray ( $ inputXml ) { $ this -> init ( ) ; if ( is_string ( $ inputXml ) ) { $ this -> xml = $ this -> createDOMDocument ( ) ; $ parsed = $ this -> xml -> loadXML ( $ inputXml ) ; if ( ! $ parsed ) { throw new \ Exception ( '[Transformer] Error parsing the XML string.' ) ; } } elseif ( $ inputXm... | Convert an XML DOMDocument or XML string to an array |
17,029 | protected function collateNamespaces ( \ DOMNode $ node ) { if ( $ this -> config [ 'useNamespaces' ] && $ node -> namespaceURI && ! array_key_exists ( $ node -> namespaceURI , $ this -> namespaces ) ) { $ this -> namespaces [ $ node -> namespaceURI ] = $ node -> lookupPrefix ( $ node -> namespaceURI ) ; } } | Get the namespace of the supplied node and add it to the list of known namespaces for this document |
17,030 | protected function getConfig ( $ requestedName , ServiceLocatorInterface $ services ) { if ( $ this -> configKey ) { $ config = $ services -> get ( 'Config' ) ; if ( ! empty ( $ config [ $ this -> configKey ] [ $ requestedName ] ) && is_array ( $ config [ $ this -> configKey ] [ $ requestedName ] ) ) { return $ config ... | Retrieves configuration options |
17,031 | protected function fetchUrl ( $ path ) { $ path .= '&format=xml' ; $ uri = new Uri ( $ this -> options -> get ( 'api.url' ) . '/api.php' . $ path ) ; if ( $ this -> options -> get ( 'api.username' , false ) ) { $ uri -> setUser ( $ this -> options -> get ( 'api.username' ) ) ; } if ( $ this -> options -> get ( 'api.pas... | Method to build and return a full request URL for the request . |
17,032 | public function buildParameter ( array $ params ) { $ path = '' ; foreach ( $ params as $ param ) { $ path .= $ param ; if ( next ( $ params ) == true ) { $ path .= '|' ; } } return $ path ; } | Method to build request parameters from a string array . |
17,033 | public function validateResponse ( Response $ response ) { $ xml = simplexml_load_string ( $ response -> body ) ; if ( isset ( $ xml -> warnings ) ) { throw new \ DomainException ( $ xml -> warnings -> info ) ; } if ( isset ( $ xml -> error ) ) { throw new \ DomainException ( $ xml -> error [ 'info' ] ) ; } return $ xm... | Method to validate response for errors |
17,034 | public function checkGii ( ) { if ( ! isset ( Yii :: $ app -> controllerMap [ $ this -> giiID ] ) ) { $ msg = "Command \"{$this->giiID}\" is not available.\n" ; $ msg .= "Please check to ensure the module is mounted and added to bootstrap phase.\n" ; $ this -> controller -> stderr ( $ msg , Console :: FG_RED ) ; Yii ::... | Check whether Gii module is loaded . |
17,035 | public static function ImageSize ( $ Path , $ Filename = FALSE ) { if ( ! $ Filename ) $ Filename = $ Path ; if ( in_array ( strtolower ( pathinfo ( $ Filename , PATHINFO_EXTENSION ) ) , array ( 'gif' , 'jpg' , 'jpeg' , 'png' ) ) ) { $ ImageSize = @ getimagesize ( $ Path ) ; if ( ! is_array ( $ ImageSize ) || ! in_arra... | Gets the image size of a file . |
17,036 | public function ValidateUpload ( $ InputName , $ ThrowError = TRUE ) { if ( ! function_exists ( 'gd_info' ) ) throw new Exception ( T ( 'The uploaded file could not be processed because GD is not installed.' ) ) ; $ TmpFileName = parent :: ValidateUpload ( $ InputName , $ ThrowError ) ; if ( $ TmpFileName ) { $ Size = ... | Validates the uploaded image . Returns the temporary name of the uploaded file . |
17,037 | public function prependSet ( $ key , $ value ) : ArrayCollection { $ this -> items = [ $ key => $ value ] + $ this -> items ; return $ this ; } | Prepends a keyed value |
17,038 | public function pull ( $ key ) { $ value = $ this -> get ( $ key ) ; $ this -> remove ( $ key ) ; return $ value ; } | Retrieves and removes a value |
17,039 | public function splice ( int $ offset , ? int $ length = null , array $ replacement = [ ] ) : ArrayCollection { if ( $ length === null && empty ( $ replacement ) ) { return new static ( array_splice ( $ this -> items , $ offset ) ) ; } if ( $ length === null ) { $ length = $ this -> count ( ) ; } return new static ( ar... | Removes and returns a portion of the collection |
17,040 | public function contains ( $ value , bool $ strict = true ) : bool { return in_array ( $ value , $ this -> items , $ strict ) ; } | Checks if a value exists |
17,041 | public function search ( $ value , bool $ strict = true ) { return array_search ( $ value , $ this -> items , $ strict ) ; } | Retrieves the key for a given value |
17,042 | public function any ( callable $ predicate ) : bool { foreach ( $ this -> items as $ key => $ value ) { if ( $ predicate ( $ value , $ key ) ) { return true ; } } return false ; } | Checks if any items pass a truth test |
17,043 | public function first ( ? callable $ predicate = null , $ default = null ) { if ( $ predicate === null ) { return $ this -> isEmpty ( ) ? $ default : reset ( $ this -> items ) ; } foreach ( $ this -> items as $ key => $ value ) { if ( $ predicate ( $ value , $ key ) ) { return $ value ; } } return $ default ; } | Retrieves the first value from the collection |
17,044 | public function last ( ? callable $ predicate = null , $ default = null ) { if ( $ predicate === null ) { return $ this -> isEmpty ( ) ? $ default : end ( $ this -> items ) ; } foreach ( array_reverse ( $ this -> items , true ) as $ key => $ value ) { if ( $ predicate ( $ value , $ key ) ) { return $ value ; } } return... | Retrieves the last value from the collection |
17,045 | public function random ( int $ amount = 1 ) { $ count = $ this -> count ( ) ; if ( $ amount > $ count ) { $ message = sprintf ( 'Requested %d items with %d items present' , $ amount , $ count ) ; throw new DomainException ( $ message ) ; } $ keys = array_rand ( $ this -> items , $ amount ) ; if ( $ amount === 1 ) { ret... | Retrieves items randomly |
17,046 | public function sort ( callable $ comparator = null ) : ArrayCollection { $ items = $ this -> items ; $ comparator ? uasort ( $ items , $ comparator ) : uasort ( $ items , function ( $ a , $ b ) { return $ a <=> $ b ; } ) ; return new static ( $ items ) ; } | Creates a sorted collection |
17,047 | public function sortBy ( callable $ callback , $ options = SORT_REGULAR , $ descending = false ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { $ items [ $ key ] = $ callback ( $ value , $ key ) ; } if ( $ descending ) { arsort ( $ items , $ options ) ; } else { asort ( $ items , ... | Creates a sorted collection using values from a callback |
17,048 | public function sortByDesc ( callable $ callback , $ options = SORT_REGULAR ) : ArrayCollection { return $ this -> sortBy ( $ callback , $ options , true ) ; } | Creates a descending sorted collection using values from a callback |
17,049 | public function each ( callable $ callback ) : ArrayCollection { foreach ( $ this -> items as $ key => $ value ) { $ callback ( $ value , $ key ) ; } return $ this ; } | Applies a callback function to every item |
17,050 | public function map ( callable $ callback ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { $ items [ $ key ] = $ callback ( $ value , $ key ) ; } return new static ( $ items ) ; } | Creates a collection from the results of a callback function |
17,051 | public function pluck ( string $ key ) : ArrayCollection { return $ this -> map ( function ( $ value ) use ( $ key ) { return $ value [ $ key ] ?? null ; } ) ; } | Creates a collection of values with a given key |
17,052 | public function keyBy ( callable $ callback ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { $ items [ $ callback ( $ value , $ key ) ] = $ value ; } return new static ( $ items ) ; } | Creates a collection keyed by keys from a callback |
17,053 | public function groupBy ( callable $ callback , bool $ preserveKeys = false ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { $ group = $ callback ( $ value , $ key ) ; if ( ! array_key_exists ( $ group , $ items ) ) { $ items [ $ group ] = new static ( ) ; } $ items [ $ group ] ->... | Creates a collection grouped by keys from a callback |
17,054 | public function chunk ( int $ size , bool $ preserveKeys = false ) : ArrayCollection { $ chunks = [ ] ; foreach ( array_chunk ( $ this -> items , $ size , $ preserveKeys ) as $ chunk ) { $ chunks [ ] = new static ( $ chunk ) ; } return new static ( $ chunks ) ; } | Creates a collection with item chunks |
17,055 | public function collapse ( ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ values ) { if ( $ values instanceof self ) { $ values = $ values -> all ( ) ; } elseif ( ! is_array ( $ values ) ) { continue ; } $ items = array_merge ( $ items , $ values ) ; } return new static ( $ items ) ; } | Creates a collection with items collapsed |
17,056 | public function zip ( ... $ items ) : ArrayCollection { $ arrayItems = array_map ( function ( $ items ) { return $ this -> itemsArray ( $ items ) ; } , $ items ) ; $ params = array_merge ( [ function ( ... $ items ) { return new static ( $ items ) ; } , $ this -> items ] , $ arrayItems ) ; return new static ( call_user... | Creates a collection zipped with the given items |
17,057 | public function unique ( ? callable $ callback = null ) : ArrayCollection { if ( $ callback === null ) { return new static ( array_unique ( $ this -> items , SORT_REGULAR ) ) ; } $ set = [ ] ; return $ this -> filter ( function ( $ value , $ key ) use ( $ callback , & $ set ) { $ hash = $ callback ( $ value , $ key ) ;... | Creates a collection with unique items |
17,058 | public function union ( $ items ) : ArrayCollection { return new static ( array_unique ( array_merge ( $ this -> items , $ this -> itemsArray ( $ items ) ) ) ) ; } | Creates a collection with the union of current and given items |
17,059 | public function filter ( callable $ predicate ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { if ( $ predicate ( $ value , $ key ) ) { $ items [ $ key ] = $ value ; } } return new static ( $ items ) ; } | Creates a collection from items that pass a truth test |
17,060 | public function reject ( callable $ predicate ) : ArrayCollection { $ items = [ ] ; foreach ( $ this -> items as $ key => $ value ) { if ( ! $ predicate ( $ value , $ key ) ) { $ items [ $ key ] = $ value ; } } return new static ( $ items ) ; } | Creates a collection from items that fail a truth test |
17,061 | public function where ( $ key , $ value , bool $ strict = true ) : ArrayCollection { return $ this -> filter ( function ( $ item ) use ( $ key , $ value , $ strict ) { if ( ! isset ( $ item [ $ key ] ) ) { return false ; } return $ strict ? $ item [ $ key ] === $ value : $ item [ $ key ] == $ value ; } ) ; } | Creates a filtered collection by key and value |
17,062 | public function whereIn ( $ key , array $ values , bool $ strict = true ) : ArrayCollection { return $ this -> filter ( function ( $ item ) use ( $ key , $ values , $ strict ) { if ( ! isset ( $ item [ $ key ] ) ) { return false ; } return in_array ( $ item [ $ key ] , $ values , $ strict ) ; } ) ; } | Creates a filtered collection by key and values |
17,063 | public function slice ( int $ offset , ? int $ length = null ) : ArrayCollection { return new static ( array_slice ( $ this -> items , $ offset , $ length , true ) ) ; } | Creates a collection from a slice of items |
17,064 | public function skip ( int $ step ) : ArrayCollection { $ items = [ ] ; $ pos = 0 ; foreach ( $ this -> items as $ key => $ value ) { if ( $ pos % $ step === 0 ) { $ items [ $ key ] = $ value ; } $ pos ++ ; } return new static ( $ items ) ; } | Creates a collection with every n - th element |
17,065 | public function partition ( callable $ predicate ) : ArrayCollection { $ items1 = [ ] ; $ items2 = [ ] ; foreach ( $ this -> items as $ key => $ value ) { if ( $ predicate ( $ value , $ key ) ) { $ items1 [ $ key ] = $ value ; } else { $ items2 [ $ key ] = $ value ; } } return new static ( [ new static ( $ items1 ) , n... | Creates a collection of two collections based on a truth test |
17,066 | public function page ( int $ page , int $ perPage ) : ArrayCollection { return $ this -> slice ( ( $ page - 1 ) * $ perPage , $ perPage ) ; } | Creates a paginated collection |
17,067 | public function implode ( ? string $ glue = null , ? callable $ callback = null ) : string { if ( $ glue === null ) { $ glue = '' ; } if ( $ callback !== null ) { return implode ( $ glue , $ this -> map ( $ callback ) -> all ( ) ) ; } return implode ( $ glue , $ this -> all ( ) ) ; } | Concatenates values into a string |
17,068 | public function join ( ? string $ glue = null , ? callable $ callback = null ) : string { return $ this -> implode ( $ glue , $ callback ) ; } | Alias for implode |
17,069 | public function reduce ( callable $ callback , $ initial = null ) { $ accumulator = $ initial ; foreach ( $ this -> items as $ key => $ value ) { $ accumulator = $ callback ( $ accumulator , $ value , $ key ) ; } return $ accumulator ; } | Reduces the collection to a single value |
17,070 | public function sum ( ? callable $ callback = null ) { if ( $ callback === null ) { $ callback = function ( $ value , $ key ) { return $ value ; } ; } return $ this -> reduce ( function ( $ total , $ value , $ key ) use ( $ callback ) { return $ total + $ callback ( $ value , $ key ) ; } , 0 ) ; } | Retrieves the sum of the collection |
17,071 | public function max ( ? callable $ callback = null ) { return $ this -> reduce ( function ( $ result , $ value , $ key ) use ( $ callback ) { if ( $ callback !== null ) { $ value = $ callback ( $ value , $ key ) ; } return ( $ result === null ) || $ value > $ result ? $ value : $ result ; } ) ; } | Retrieves the maximum value for a collection |
17,072 | public function min ( ? callable $ callback = null ) { return $ this -> reduce ( function ( $ result , $ value , $ key ) use ( $ callback ) { if ( $ callback !== null ) { $ value = $ callback ( $ value , $ key ) ; } return ( $ result === null ) || $ value < $ result ? $ value : $ result ; } ) ; } | Retrieves the minimum value for a collection |
17,073 | protected static function flattenArray ( array $ array , int $ depth = PHP_INT_MAX ) : array { $ items = [ ] ; foreach ( $ array as $ item ) { if ( $ item instanceof self ) { $ item = $ item -> all ( ) ; } if ( is_array ( $ item ) ) { if ( $ depth === 1 ) { $ items = array_merge ( $ items , $ item ) ; continue ; } $ it... | Flattens a multi - dimensional array into a single level |
17,074 | protected function itemsArray ( $ items ) : array { if ( is_array ( $ items ) ) { return $ items ; } elseif ( $ items instanceof self ) { return $ items -> all ( ) ; } elseif ( $ items instanceof Arrayable ) { return $ items -> toArray ( ) ; } return ( array ) $ items ; } | Retrieves items as an array |
17,075 | public function ok ( $ data , int $ status = 200 , int $ encodingOptions = 0 ) { $ this -> validHttpCode ( $ status ) ; return parent :: withJson ( $ data , $ status , $ encodingOptions ) ; } | Response data with 2xx status code |
17,076 | public function runControllerWithParameters ( $ parameters = [ ] ) { $ this -> setParameters ( $ this -> toArray ( $ parameters ) ) ; foreach ( $ this -> callbacks as $ callback ) { $ this -> app -> call ( $ callback ) ; } } | register parameters and run constructors |
17,077 | public function handle ( ) { Log :: debug ( "ArtisanCommand handle begin $this->command_string" ) ; $ input = new StringInput ( $ this -> command_string ) ; $ output = new PusherChannelOutput ( ) ; $ pusher = Broadcast :: connection ( ) -> getPusher ( ) ; $ channel_id = config ( 'platformadmin.console.pusher_channel_ba... | handle the job |
17,078 | public static function endpointsInfo ( Application $ app ) { $ app -> boot ( ) ; $ controllers = $ app [ 'controllers' ] ; $ rControllers = new ReflectionObject ( $ controllers ) ; $ pControllers = $ rControllers -> getProperty ( 'controllers' ) ; $ pControllers -> setAccessible ( true ) ; foreach ( $ pControllers -> g... | Simple method to print application resources . |
17,079 | protected function buildPagination ( ) { $ this -> calculateDisplayRange ( ) ; $ pages = array ( ) ; for ( $ i = $ this -> displayRangeStart ; $ i <= $ this -> displayRangeEnd ; $ i ++ ) { $ pages [ ] = array ( 'number' => $ i , 'isCurrent' => ( $ i === $ this -> currentPage ) ) ; } $ pagination = array ( 'pages' => $ ... | Returns an array with the keys pages current numberOfPages nextPage & previousPage |
17,080 | public static function create_from_string ( $ input , $ pattern_key = 'local' ) { \ Config :: load ( 'date' , 'date' ) ; $ pattern = \ Config :: get ( 'date.patterns.' . $ pattern_key , null ) ; empty ( $ pattern ) and $ pattern = $ pattern_key ; $ time = strptime ( $ input , $ pattern ) ; if ( $ time === false ) { thr... | Uses the date config file to translate string input to timestamp |
17,081 | public static function range_to_array ( $ start , $ end , $ interval = '+1 Day' ) { $ start = ( ! $ start instanceof Date ) ? static :: forge ( $ start ) : $ start ; $ end = ( ! $ end instanceof Date ) ? static :: forge ( $ end ) : $ end ; is_int ( $ interval ) or $ interval = strtotime ( $ interval , $ start -> get_ti... | Fetches an array of Date objects per interval within a range |
17,082 | public static function time_ago ( $ timestamp , $ from_timestamp = null , $ unit = null ) { if ( $ timestamp === null ) { return '' ; } ! is_numeric ( $ timestamp ) and $ timestamp = static :: create_from_string ( $ timestamp ) -> get_timestamp ( ) ; $ from_timestamp == null and $ from_timestamp = time ( ) ; \ Lang :: ... | Returns the time ago |
17,083 | public function format ( $ pattern_key = 'local' , $ timezone = null ) { \ Config :: load ( 'date' , 'date' ) ; $ pattern = \ Config :: get ( 'date.patterns.' . $ pattern_key , $ pattern_key ) ; $ timezone === true and $ timezone = static :: $ display_timezone ; is_string ( $ timezone ) or $ timezone = $ this -> timezo... | Returns the date formatted according to the current locale |
17,084 | public function get_timezone_abbr ( $ display_timezone = false ) { $ display_timezone and $ timezone = static :: $ display_timezone ; empty ( $ timezone ) and $ timezone = $ this -> timezone ; if ( \ Fuel :: $ timezone != $ timezone ) { date_default_timezone_set ( $ timezone ) ; } $ output = date ( 'T' ) ; if ( \ Fuel ... | Returns the internal timezone or the display timezone abbreviation |
17,085 | protected function send ( ) { try { $ options = $ this -> getOptions ( ) ; $ message = sprintf ( 'Service: %2$s' . PHP_EOL . 'Host: %3$s' . PHP_EOL . 'State: %5$s' . PHP_EOL . 'Message: %7$s' , $ options [ 'type' ] , $ options [ 'service' ] , $ options [ 'host' ] , $ options [ 'address' ] , $ options [ 'state' ] , $ op... | Sends the notification to the given Android device . |
17,086 | protected function determinePriority ( $ state ) { $ priority = 0 ; if ( array_key_exists ( $ state , $ this -> stateToPriorityMap ) ) { $ priority = $ this -> stateToPriorityMap [ $ state ] ; } return $ priority ; } | Returns the priority for the given host or service state . |
17,087 | public function getDescription ( ) { if ( empty ( $ this -> paragraphId ) ) { return '' ; } $ model = $ this -> getServiceLocator ( ) -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) ; $ locale = $ model -> getLocale ( ) ; $ model -> setLocale ( $ this -> locale ) ; $ content = $ model -> find ( $ this -> paragraphId ... | Get description for this log - event |
17,088 | protected function getRelationClosure ( Entity $ entity , Attribute $ attribute ) { $ method = $ attribute -> is_collection ? 'hasMany' : 'hasOne' ; return Closure :: bind ( function ( ) use ( $ entity , $ attribute , $ method ) { $ relation = $ entity -> $ method ( $ attribute -> getAttribute ( 'type' ) , 'entity_id' ... | Generate the entity attribute relation closure . |
17,089 | public final function getHeaderValue ( $ name ) { self :: checkString ( $ name ) ; foreach ( $ this -> _headers as $ headerName => $ headerValue ) { if ( strcasecmp ( $ name , $ headerName ) === 0 ) { return $ headerValue ; } } return null ; } | Find a header value by header name . |
17,090 | public final function setHeader ( $ name , $ value ) { self :: checkString ( $ name ) ; self :: checkString ( $ value ) ; $ this -> _headers [ $ name ] = $ value ; } | Set a single header . |
17,091 | public final function removeHeaders ( $ name ) { self :: checkString ( $ name ) ; foreach ( $ this -> _headers as $ headerName => $ headerValue ) { if ( strcasecmp ( $ name , $ headerName ) === 0 ) { unset ( $ this -> _headers [ $ headerName ] ) ; } } } | Removes any headers with the given name . |
17,092 | public function commit ( $ pWithChilds = false ) { try { $ prepared = Agl :: app ( ) -> getDb ( ) -> getConnection ( ) -> prepare ( " DELETE FROM `" . $ this -> getDbPrefix ( ) . $ this -> _item -> getDbContainer ( ) . "` WHERE `" . $ th... | Commit the deletion to Mysql and check the query result . |
17,093 | public function set ( $ key , $ value , \ DatePeriod $ period = null ) { if ( is_null ( $ period ) ) { $ this -> repository -> set ( $ key , $ value ) ; } else { $ this -> setForPeriod ( $ key , $ value , $ period ) ; } } | Set value for a key . |
17,094 | public function get ( $ key , \ DatePeriod $ period = null ) { if ( is_null ( $ period ) ) { return new Value ( $ this -> repository -> get ( $ key ) ) ; } return $ this -> getForPeriod ( $ key , $ period ) ; } | Get value for a key . |
17,095 | protected function getForPeriod ( $ key , \ DatePeriod $ period ) { $ ranges = $ this -> getRanges ( $ period ) ; if ( count ( $ ranges ) > 0 ) { if ( count ( $ ranges ) == 1 && ! ( $ ranges [ 0 ] instanceof DateRange ) ) { return new DateValue ( $ ranges [ 0 ] , $ this -> repository -> getFor ( $ key , $ ranges [ 0 ] ... | Return value for a given period . |
17,096 | public function has ( $ key , \ DatePeriod $ period = null ) { if ( is_null ( $ period ) ) { return new Exists ( $ this -> repository -> has ( $ key ) ) ; } return $ this -> hasForPeriod ( $ key , $ period ) ; } | Determine if value exists . |
17,097 | protected function hasForPeriod ( $ key , \ DatePeriod $ period ) { $ ranges = $ this -> getRanges ( $ period ) ; if ( count ( $ ranges ) > 0 ) { if ( count ( $ ranges ) == 1 && ! ( $ ranges [ 0 ] instanceof DateRange ) ) { return new DateExists ( $ ranges [ 0 ] , $ this -> repository -> hasFor ( $ key , $ ranges [ 0 ]... | Determine if value exists for given period . |
17,098 | public function increment ( $ key , $ value , \ DatePeriod $ period = null ) { if ( is_null ( $ period ) ) { $ this -> repository -> increment ( $ key , $ value ) ; } else { $ this -> incrementForPeriod ( $ key , $ value , $ period ) ; } } | Increment value . |
17,099 | protected function incrementForPeriod ( $ key , $ value , \ DatePeriod $ period ) { $ ranges = $ this -> getRanges ( $ period ) ; if ( count ( $ ranges ) > 0 ) { foreach ( $ ranges as $ range ) { $ range instanceof DateRange ? $ this -> repository -> incrementForRange ( $ key , $ range -> getStartDate ( ) , $ range -> ... | Increment value for a given period . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.