PHP 클래스 Yosymfony\Spress\Core\Support\ArrayWrapper

Based on https://github.com/laravel/framework/blob/5.0/src/Illuminate/Support/Arr.php
저자: Victor Puertas ([email protected])
파일 보기 프로젝트 열기: spress/spress 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$array

공개 메소드들

메소드 설명
__construct ( array $array = [] ) Constructor.
add ( $key, $value ) : array Adds an element using "dot" notation if doesn't exists.
flatten ( ) : array Flatten a multi-dimensional array into a single level.
get ( string $key, mixed $default = null ) : mixed Gets a value from a deeply nested array using "dot" notation.
getArray ( ) : array Gets the working array.
has ( string $key ) : boolean Checks if an item exists in using "dot" notation.
paginate ( integer $maxPerPage, integer $initialPage = 1, string $key = null ) : array Paginates the array.
remove ( string $key ) : array Removes an item using "dot" notation.
set ( string $key, mixed $value ) : array Sets an item using "dot" notation.
setArray ( array $array ) : ArrayWrapper Sets the working array.
sort ( string $key = null, callable $callback = null ) : array Sorts the array (ascendant by default).
sortBy ( callable $callback, string $key = null, integer $options = SORT_REGULAR, boolean $isDescending = false ) : array Sort the array sing the given callback.
where ( callable $filter ) : array Filter using the given callback function.

보호된 메소드들

메소드 설명
escapedDotKeyToUnderscore ( $key )
underscoreDotKeyToDot ( $key )
unescapeDotKey ( $key )

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $array = [] )
$array array

add() 공개 메소드

You can to escape a dot in a key surrendering with brackets: "[.]".
public add ( $key, $value ) : array
$key
$value
리턴 array

escapedDotKeyToUnderscore() 보호된 메소드

protected escapedDotKeyToUnderscore ( $key )

flatten() 공개 메소드

Flatten a multi-dimensional array into a single level.
public flatten ( ) : array
리턴 array A single level array

get() 공개 메소드

You can to escape a dot in a key surrendering with brackets: "[.]". e.g: $a->get('site.data') or $a->get('site.pages.index[.]html')
public get ( string $key, mixed $default = null ) : mixed
$key string
$default mixed
리턴 mixed

getArray() 공개 메소드

Gets the working array.
public getArray ( ) : array
리턴 array

has() 공개 메소드

You can to escape a dot in a key surrendering with brackets: "[.]".
public has ( string $key ) : boolean
$key string
리턴 boolean

paginate() 공개 메소드

Paginates the array.
public paginate ( integer $maxPerPage, integer $initialPage = 1, string $key = null ) : array
$maxPerPage integer Max items per page. If this value is minor than 1 the result will be an empty array
$initialPage integer Initial page. Page 1 by default
$key string Element to paginate using "dot" notation
리턴 array A list of pages with an array of elements associated with each page

remove() 공개 메소드

Removes an item using "dot" notation.
public remove ( string $key ) : array
$key string
리턴 array

set() 공개 메소드

You can to escape a dot in a key surrendering with brackets: "[.]".
public set ( string $key, mixed $value ) : array
$key string
$value mixed
리턴 array

setArray() 공개 메소드

Sets the working array.
public setArray ( array $array ) : ArrayWrapper
$array array
리턴 ArrayWrapper This instance

sort() 공개 메소드

Sorts the array (ascendant by default).
public sort ( string $key = null, callable $callback = null ) : array
$key string Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]"
$callback callable Callback should be a function with the following signature: ```php function($element1, $element2) { // returns -1, 0 or 1 } ```
리턴 array

sortBy() 공개 메소드

Sort the array sing the given callback.
public sortBy ( callable $callback, string $key = null, integer $options = SORT_REGULAR, boolean $isDescending = false ) : array
$callback callable Callback should be a function with the following signature: ```php function($key, $value) { // return $processedValue; } ```
$key string Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]"
$options integer See sort_flags at http://php.net/manual/es/function.sort.php
$isDescending boolean
리턴 array

underscoreDotKeyToDot() 보호된 메소드

protected underscoreDotKeyToDot ( $key )

unescapeDotKey() 보호된 메소드

protected unescapeDotKey ( $key )

where() 공개 메소드

Filter using the given callback function.
public where ( callable $filter ) : array
$filter callable The filter function should be a function with the following signature: ```php function($key, $value) { // returns true if the value is matching your criteria. } ```
리턴 array

프로퍼티 상세

$array 보호되어 있는 프로퍼티

protected $array