PHP 클래스 Arrayzy\AbstractArray

저자: Victor Bocharsky ([email protected])
상속: implements ArrayAcces\ArrayAccess, implements Arrayzy\Interfaces\ConvertibleInterface, implements Countabl\Countable, implements Arrayzy\Interfaces\DebuggableInterface, implements IteratorAggregat\IteratorAggregate, implements Arrayzy\Interfaces\ModifiableInterface, implements Arrayzy\Interfaces\SortableInterface, implements Arrayzy\Interfaces\TraversableInterface, use trait Arrayzy\Traits\ConvertibleTrait, use trait Arrayzy\Traits\DebuggableTrait, use trait Arrayzy\Traits\ModifiableTrait, use trait Arrayzy\Traits\TraversableTrait
파일 보기 프로젝트 열기: bocharsky-bw/arrayzy 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$elements array

공개 메소드들

메소드 설명
__construct ( array $elements = [] ) Construct new instance
chunk ( integer $size, boolean $preserveKeys = false ) : AbstractArray Create a chunked version of current array.
clear ( ) : AbstractArray Clear the current array.
combine ( array $array ) : AbstractArray Create an array using the current array as keys and the other array as values.
contains ( mixed $element ) : boolean Check if the given value exists in the array.
containsKey ( mixed $key ) : boolean Check if the given key/index exists in the array.
count ( ) : integer Returns the number of values in the array.
create ( array $elements = [] ) : AbstractArray Create a new instance.
createClone ( ) : AbstractArray Clone current instance to new instance.
createFromJson ( string $json, integer $options, integer $depth = 512 ) : AbstractArray Decode a JSON string to new instance.
createFromObject ( ArrayAccess $elements ) : AbstractArray Create a new instance filled with values from an object implementing ArrayAccess.
createFromString ( string $string, string $separator ) : AbstractArray Explode a string to new instance by specified separator.
createWithRange ( mixed $low, mixed $high, integer $step = 1 ) : AbstractArray Create a new instance containing a range of elements.
diff ( array $array ) : AbstractArray Compute the current array values which not present in the given one.
except ( array $keys ) : AbstractArray Return slice of an array except given keys.
exists ( callable $func ) : boolean Find the given value in An array using a closure
filter ( callable $func ) : AbstractArray Filter the current array for elements satisfying the predicate $func.
find ( callable $func ) : mixed Returns the first occurrence of a value that satisfies the predicate $func.
flip ( ) : AbstractArray Exchanges all keys of current array with their associated values.
getIterator ( ) : Traversable Create an iterator over this array.
getKeys ( ) : array Return an array all the keys of this array.
getRandom ( ) : mixed Pick a random value out of this array.
getRandomKey ( ) : mixed Pick a random key/index from the keys of this array.
getRandomKeys ( integer $number ) : mixed Pick a given number of random keys/indexes out of this array.
getRandomValues ( integer $number ) : array Pick a given number of random values with non-duplicate indexes out of the array.
getValues ( ) : mixed Return an array of all values from this array numerically indexed.
indexOf ( mixed $element ) : mixed Alias of search() method. Search for a given element and return the index of its first occurrence.
intersect ( array $array ) : AbstractArray Compute the current array values which present in the given one.
intersectAssoc ( array $array ) : AbstractArray Compute the current array values with additional index check which present in the given one.
intersectKey ( array $array ) : AbstractArray Compute the current array using keys for comparison which present in the given one.
isAssoc ( ) : boolean Check whether array is associative or not.
isEmpty ( ) : boolean Check whether the array is empty or not.
isNumeric ( ) : boolean Check whether array is numeric or not.
map ( callable $func ) : AbstractArray Apply the given function to the every element of the current array, collecting the results.
merge ( array $array, boolean $recursively = false ) : AbstractArray Merge the current array with the provided one. The latter array is overwriting.
offsetExists ( mixed $offset ) : boolean Whether an offset exists.
offsetGet ( mixed $offset ) : mixed Retrieve the current offset or null.
offsetSet ( mixed $offset, mixed $value ) Set an offset for this array.
offsetUnset ( mixed $offset ) Remove a present offset.
only ( array $keys ) : AbstractArray Return slice of an array with just a given keys.
pad ( integer $size, mixed $value ) : AbstractArray Pad the current array to the specified size with a given value.
reduce ( callable $func, mixed | null $initial = null ) : mixed Reduce the array to a single value iteratively combining all values using $func.
reindex ( ) : AbstractArray Create a numerically re-indexed array based on the current array.
replace ( array $array, boolean $recursively = false ) : AbstractArray Replace values in the current array with values in the given one that have the same key.
reverse ( boolean $preserveKeys = false ) : AbstractArray Reverse the values order of the current array.
search ( mixed $element ) : mixed Search for a given element and return the index of its first occurrence.
shuffle ( ) : AbstractArray Randomize elements order of the current array.
slice ( integer $offset, integer | null $length = null, boolean $preserveKeys = false ) : AbstractArray Extract a slice of the current array.
unique ( integer | null $sortFlags = null ) : AbstractArray Remove duplicate values from the current array.
walk ( callable $func, boolean $recursively = false ) : AbstractArray Apply the given function to the every element of the current array, discarding the results.

비공개 메소드들

메소드 설명
checkType ( string $type ) : boolean Check if an array keys are in a given variable type.

메소드 상세

__construct() 공개 메소드

Construct new instance
public __construct ( array $elements = [] )
$elements array

chunk() 추상적인 공개 메소드

Create a chunked version of current array.
abstract public chunk ( integer $size, boolean $preserveKeys = false ) : AbstractArray
$size integer Size of each chunk
$preserveKeys boolean Whether array keys are preserved or no
리턴 AbstractArray An array of chunks from the current array

clear() 추상적인 공개 메소드

Clear the current array.
abstract public clear ( ) : AbstractArray
리턴 AbstractArray The current empty array

combine() 추상적인 공개 메소드

Create an array using the current array as keys and the other array as values.
abstract public combine ( array $array ) : AbstractArray
$array array Values array
리턴 AbstractArray An array with values from the other array

contains() 공개 메소드

Check if the given value exists in the array.
public contains ( mixed $element ) : boolean
$element mixed Value to search for
리턴 boolean Returns true if the given value exists in the array, false otherwise

containsKey() 공개 메소드

Check if the given key/index exists in the array.
public containsKey ( mixed $key ) : boolean
$key mixed Key/index to search for
리턴 boolean Returns true if the given key/index exists in the array, false otherwise

count() 공개 메소드

Returns the number of values in the array.
public count ( ) : integer
리턴 integer total number of values

create() 공개 정적인 메소드

Create a new instance.
public static create ( array $elements = [] ) : AbstractArray
$elements array
리턴 AbstractArray Returns created instance

createClone() 공개 메소드

Clone current instance to new instance.
사용 중단: Should be removed
public createClone ( ) : AbstractArray
리턴 AbstractArray Shallow copy of $this

createFromJson() 공개 정적인 메소드

Decode a JSON string to new instance.
public static createFromJson ( string $json, integer $options, integer $depth = 512 ) : AbstractArray
$json string The JSON string being decoded
$options integer Bitmask of JSON decode options
$depth integer Specified recursion depth
리턴 AbstractArray The created array

createFromObject() 공개 정적인 메소드

Create a new instance filled with values from an object implementing ArrayAccess.
public static createFromObject ( ArrayAccess $elements ) : AbstractArray
$elements ArrayAccess Object that implements ArrayAccess
리턴 AbstractArray Returns created instance

createFromString() 공개 정적인 메소드

Explode a string to new instance by specified separator.
public static createFromString ( string $string, string $separator ) : AbstractArray
$string string Converted string
$separator string Element's separator
리턴 AbstractArray The created array

createWithRange() 공개 정적인 메소드

Create a new instance containing a range of elements.
public static createWithRange ( mixed $low, mixed $high, integer $step = 1 ) : AbstractArray
$low mixed First value of the sequence
$high mixed The sequence is ended upon reaching the end value
$step integer Used as the increment between elements in the sequence
리턴 AbstractArray The created array

diff() 추상적인 공개 메소드

Compute the current array values which not present in the given one.
abstract public diff ( array $array ) : AbstractArray
$array array Array for diff
리턴 AbstractArray An array containing all the entries from this array that are not present in $array

except() 공개 메소드

Return slice of an array except given keys.
public except ( array $keys ) : AbstractArray
$keys array List of keys to exclude
리턴 AbstractArray The created array

exists() 공개 메소드

Find the given value in An array using a closure
public exists ( callable $func ) : boolean
$func callable
리턴 boolean Returns true if the given value is found, false otherwise

filter() 추상적인 공개 메소드

Filter the current array for elements satisfying the predicate $func.
abstract public filter ( callable $func ) : AbstractArray
$func callable
리턴 AbstractArray An array with only element satisfying $func

find() 공개 메소드

Returns the first occurrence of a value that satisfies the predicate $func.
public find ( callable $func ) : mixed
$func callable
리턴 mixed The first occurrence found

flip() 추상적인 공개 메소드

Exchanges all keys of current array with their associated values.
abstract public flip ( ) : AbstractArray
리턴 AbstractArray An array with flipped elements

getIterator() 공개 메소드

Create an iterator over this array.
public getIterator ( ) : Traversable
리턴 Traversable An instance of an object implementing Iterator

getKeys() 공개 메소드

Return an array all the keys of this array.
public getKeys ( ) : array
리턴 array An array of all keys

getRandom() 공개 메소드

Pick a random value out of this array.
public getRandom ( ) : mixed
리턴 mixed Random value of array

getRandomKey() 공개 메소드

Pick a random key/index from the keys of this array.
public getRandomKey ( ) : mixed
리턴 mixed Random key/index of array

getRandomKeys() 공개 메소드

Pick a given number of random keys/indexes out of this array.
public getRandomKeys ( integer $number ) : mixed
$number integer The number of keys/indexes (should be <= $this->count())
리턴 mixed Random keys or key of array

getRandomValues() 공개 메소드

Pick a given number of random values with non-duplicate indexes out of the array.
public getRandomValues ( integer $number ) : array
$number integer The number of values (should be > 1 and < $this->count())
리턴 array Random values of array

getValues() 공개 메소드

Return an array of all values from this array numerically indexed.
public getValues ( ) : mixed
리턴 mixed An array of all values

indexOf() 공개 메소드

Alias of search() method. Search for a given element and return the index of its first occurrence.
public indexOf ( mixed $element ) : mixed
$element mixed Value to search for
리턴 mixed The corresponding key/index

intersect() 추상적인 공개 메소드

Compute the current array values which present in the given one.
abstract public intersect ( array $array ) : AbstractArray
$array array Array for intersect
리턴 AbstractArray An array with containing all the entries from this array that are present in $array

intersectAssoc() 추상적인 공개 메소드

Compute the current array values with additional index check which present in the given one.
abstract public intersectAssoc ( array $array ) : AbstractArray
$array array Array for intersect
리턴 AbstractArray An array with containing all the entries from this array that are present in $array. Note that the keys are also used in the comparison unlike in intersect().

intersectKey() 추상적인 공개 메소드

Compute the current array using keys for comparison which present in the given one.
abstract public intersectKey ( array $array ) : AbstractArray
$array array Array for intersect
리턴 AbstractArray An array with containing all the entries from this array which have keys that are present in $array.

isAssoc() 공개 메소드

Check whether array is associative or not.
public isAssoc ( ) : boolean
리턴 boolean Returns true if associative, false otherwise

isEmpty() 공개 메소드

Check whether the array is empty or not.
public isEmpty ( ) : boolean
리턴 boolean Returns true if empty, false otherwise

isNumeric() 공개 메소드

Check whether array is numeric or not.
public isNumeric ( ) : boolean
리턴 boolean Returns true if numeric, false otherwise

map() 추상적인 공개 메소드

Apply the given function to the every element of the current array, collecting the results.
abstract public map ( callable $func ) : AbstractArray
$func callable
리턴 AbstractArray An array with modified elements

merge() 추상적인 공개 메소드

Merge the current array with the provided one. The latter array is overwriting.
abstract public merge ( array $array, boolean $recursively = false ) : AbstractArray
$array array Array to merge with (overwrites)
$recursively boolean Whether array will be merged recursively or no
리턴 AbstractArray An array with the keys/values from $array added

offsetExists() 공개 메소드

Whether an offset exists.
public offsetExists ( mixed $offset ) : boolean
$offset mixed An offset to check for.
리턴 boolean true on success or false on failure.

offsetGet() 공개 메소드

Retrieve the current offset or null.
public offsetGet ( mixed $offset ) : mixed
$offset mixed The offset to retrieve.
리턴 mixed Can return all value types.

offsetSet() 공개 메소드

Set an offset for this array.
public offsetSet ( mixed $offset, mixed $value )
$offset mixed The offset to assign the value to.
$value mixed The value to set.

offsetUnset() 공개 메소드

Remove a present offset.
public offsetUnset ( mixed $offset )
$offset mixed The offset to unset.

only() 공개 메소드

Return slice of an array with just a given keys.
public only ( array $keys ) : AbstractArray
$keys array List of keys to return
리턴 AbstractArray The created array

pad() 추상적인 공개 메소드

Pad the current array to the specified size with a given value.
abstract public pad ( integer $size, mixed $value ) : AbstractArray
$size integer Size of the result array
$value mixed Empty value by default
리턴 AbstractArray An array padded to $size with $value

reduce() 공개 메소드

Reduce the array to a single value iteratively combining all values using $func.
public reduce ( callable $func, mixed | null $initial = null ) : mixed
$func callable callback ($carry, $item) -> next $carry
$initial mixed | null starting value of the $carry
리턴 mixed Final value of $carry

reindex() 추상적인 공개 메소드

Create a numerically re-indexed array based on the current array.
abstract public reindex ( ) : AbstractArray
리턴 AbstractArray An array with re-indexed elements

replace() 추상적인 공개 메소드

Replace values in the current array with values in the given one that have the same key.
abstract public replace ( array $array, boolean $recursively = false ) : AbstractArray
$array array Array of replacing values
$recursively boolean Whether array will be replaced recursively or no
리턴 AbstractArray An array with the same keys but new values

reverse() 추상적인 공개 메소드

Reverse the values order of the current array.
abstract public reverse ( boolean $preserveKeys = false ) : AbstractArray
$preserveKeys boolean Whether array keys are preserved or no
리턴 AbstractArray An array with the order of the elements reversed

shuffle() 추상적인 공개 메소드

Randomize elements order of the current array.
abstract public shuffle ( ) : AbstractArray
리턴 AbstractArray An array with the shuffled elements order

slice() 추상적인 공개 메소드

Extract a slice of the current array.
abstract public slice ( integer $offset, integer | null $length = null, boolean $preserveKeys = false ) : AbstractArray
$offset integer Slice begin index
$length integer | null Length of the slice
$preserveKeys boolean Whether array keys are preserved or no
리턴 AbstractArray A new array, which is slice of the current array with specified $length

unique() 추상적인 공개 메소드

Remove duplicate values from the current array.
abstract public unique ( integer | null $sortFlags = null ) : AbstractArray
$sortFlags integer | null
리턴 AbstractArray An array with only unique elements

walk() 추상적인 공개 메소드

Apply the given function to the every element of the current array, discarding the results.
abstract public walk ( callable $func, boolean $recursively = false ) : AbstractArray
$func callable
$recursively boolean Whether array will be walked recursively or no
리턴 AbstractArray An array with modified elements

프로퍼티 상세

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

protected array $elements
리턴 array