|
| __construct ($data=[]) |
|
| exchangeArray ($input) |
|
| toArray () |
|
| append ($newval) |
|
| offsetSet ($index, $newval) |
|
| offsetUnset ($index) |
|
| setFinder (callable $finder) |
|
| getDeleted () |
|
| refresh () |
|
| findBy ($key, $values, $op= '==') |
|
| findOneBy ($key, $values, $op= '==') |
|
| each (callable $func) |
|
| map (callable $func) |
|
| filter (callable $func=null, $limit=null) |
|
| any (callable $func) |
|
| every (callable $func) |
|
| pluck ($columns) |
|
| toGroupedArray ($group_by= 'id', $only_these_fields=null, callable $group_func=null) |
|
| first () |
|
| last () |
|
| val ($key) |
|
| unsetBy ($key, $values, $op= '==') |
|
| orderBy ($order, $sort_flags=SORT_LOCALE_STRING) |
|
| limit ($arg1, $arg2=null) |
|
| sendMessage ($method, $params=[]) |
|
| __call ($method, $params) |
|
| merge (SimpleCollection $a_collection) |
|
| __construct ($input=[], $flags=self::STD_PROP_LIST, $iteratorClass= 'ArrayIterator') |
|
| __isset ($key) |
|
| __set ($key, $value) |
|
| __unset ($key) |
|
| __get ($key) |
|
| append ($value) |
|
| asort () |
|
| count () |
|
| exchangeArray ($data) |
|
| getArrayCopy () |
|
| getFlags () |
|
| getIterator () |
|
| getIteratorClass () |
|
| ksort () |
|
| natcasesort () |
|
| natsort () |
|
| offsetExists ($key) |
|
| offsetGet ($key) |
|
| offsetSet ($key, $value) |
|
| offsetUnset ($key) |
|
| serialize () |
|
| setFlags ($flags) |
|
| setIteratorClass ($class) |
|
| uasort ($function) |
|
| uksort ($function) |
|
| unserialize ($data) |
|
| contains ($value) |
|
__construct |
( |
|
$data = [] | ) |
|
Constructor
- Parameters
-
array<T>|callable(),: | array<T> $data array or closure to fill collection |
__call |
( |
|
$method, |
|
|
|
$params |
|
) |
| |
magic version of sendMessage calls undefineds methods on all elements of the collection But beware of the dark side...
- Parameters
-
literal-string | $method | methodname to call |
array | $params | parameters for methodcall |
- Returns
- array of all return values
Returns whether any element of the collection returns true for the given callback.
- Parameters
-
callable(T,mixed),: | bool $func the function to call |
- Returns
- bool
- See Also
- ArrayObject::append()
static arrayToArrayObject |
( |
|
$a | ) |
|
|
static |
converts arrays or objects to ArrayObject objects if ArrayAccess interface is not available
- Parameters
-
- Returns
- StudipArrayObject|ArrayAccess
static createFromArray |
( |
array |
$data | ) |
|
|
static |
creates a collection from an array of arrays all arrays should contain same keys, but is not enforced
- Parameters
-
array<T> | $data array containing assoc arrays |
- Returns
- SimpleCollection<T>
apply given callback to all elements of collection
- Parameters
-
callable(T),: | int $func the function to call |
- Returns
- int|false addition of return values
Returns whether every element of the collection returns true for the given callback.
- Parameters
-
callable(T,mixed),: | bool $func the function to call |
- Returns
- bool
filter |
( |
callable |
$func = null , |
|
|
|
$limit = null |
|
) |
| |
filter elements if given callback returns true
- Parameters
-
?callable(T,mixed),: | bool $func the function to call |
?integer | $limit limit number of found records |
- Returns
- SimpleCollection<T> containing filtered elements
findBy |
( |
|
$key, |
|
|
|
$values, |
|
|
|
$op = '==' |
|
) |
| |
returns a new collection containing all elements where given columns value matches given value(s) using passed operator pass array for multiple values
operators: == equal, like php === identical, like php !=,<> not equal, like php !== not identical, like php <,>,<=,>= less,greater,less or equal,greater or equal >< between without borders, needs two arguments >=<= between including borders, needs two arguments %= like string, transliterate to ascii,case insensitive *= contains string ^= begins with string $= ends with string ~= regex
- Parameters
-
string | $key | the column name |
mixed | $values | value to search for |
string | callable | $op | operator to find |
- Returns
- SimpleCollection<T> with found records
findOneBy |
( |
|
$key, |
|
|
|
$values, |
|
|
|
$op = '==' |
|
) |
| |
returns the first element where given column has given value(s) pass array for multiple values
- Parameters
-
string | $key | the column name |
mixed | $values | value to search for, |
string | callable | $op | operator to find |
- Returns
- ?T found record
get the first element
- Returns
- ?T first element or null
static getCompFunc |
( |
|
$operator, |
|
|
|
$args |
|
) |
| |
|
static |
returns closure to compare a value against given arguments using given operator
- Parameters
-
| string|callable(mixed,mixed|array),: | bool $operator |
mixed | array | $args | |
- Exceptions
-
- Returns
- callable(mixed): bool comparison function
get deleted records collection
- Returns
- SimpleCollection<T>
get the last element
- Returns
- ?T last element or null
limit |
( |
|
$arg1, |
|
|
|
$arg2 = null |
|
) |
| |
returns a new collection contaning a sequence of original collection mimics the sql limit constrain: used with one parameter, the first x elements are extracted used with two parameters, the first parameter denotes the offset, the second the number of elements
- Parameters
-
integer | $arg1 | |
| ?integer | $arg2 |
- Returns
- SimpleCollection<T>
apply given callback to all elements of collection and give back array of return values
- Parameters
-
callable(T,mixed),: | mixed $func the function to call |
- Returns
- array<mixed>
merge in another collection, elements are appended
- Parameters
-
SimpleCollection<T> | $a_collection |
- Returns
- void
offsetSet |
( |
|
$index, |
|
|
|
$newval |
|
) |
| |
Sets the value at the specified index ensures the value has ArrayAccess
- Parameters
-
- See Also
- ArrayObject::offsetSet()
- Returns
- void
Unsets the value at the specified index value is moved to internal deleted collection
- See Also
- ArrayObject::offsetUnset()
- Exceptions
-
orderBy |
( |
|
$order, |
|
|
|
$sort_flags = SORT_LOCALE_STRING |
|
) |
| |
sorts the collection by columns of contained elements and returns it
works like sql order by: first param is a string containing combinations of column names and sort direction, separated by comma e.g. 'name asc, nummer desc ' sorts first by name ascending and then by nummer descending second param denotes the sort type (using PHP sort constants): SORT_LOCALE_STRING: compare items as strings, transliterate latin1 to ascii, case insensitiv, natural order for numbers SORT_NUMERIC: compare items as integers SORT_STRING: compare items as strings SORT_NATURAL: compare items as strings using "natural ordering" SORT_FLAG_CASE: can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
- Parameters
-
string | $order | columns to order by |
integer | $sort_flags | |
- Returns
- $this the sorted collection
extract array of columns values pass array or space-delimited string for multiple columns
- Parameters
-
string | array | $columns | the column(s) to extract |
- Returns
- array of extracted values
reloads the elements of the collection by calling the finder function
- Returns
- ?int of records after refresh
sendMessage |
( |
|
$method, |
|
|
|
$params = [] |
|
) |
| |
calls the given method on all elements of the collection
- Parameters
-
literal-string | $method | methodname to call |
array | $params | parameters for methodcall |
- Returns
- array of all return values
setFinder |
( |
callable |
$finder | ) |
|
sets the finder function
- Parameters
-
callable(),: | array<T> $finder |
- Returns
- void
converts the object and all elements to plain arrays
- Returns
- array
toGroupedArray |
( |
|
$group_by = 'id' , |
|
|
|
$only_these_fields = null , |
|
|
callable |
$group_func = null |
|
) |
| |
returns the collection as grouped array first param is the column to group by, it becomes the key in the resulting array, default is pk. Limit returned fields with second param The grouped entries can optoionally go through the given callback. If no callback is provided, only the first grouped entry is returned, suitable for grouping by unique column
- Parameters
-
string | $group_by | the column to group by, pk if ommitted |
string | array | null | $only_these_fields | limit returned fields |
| ?callable | $group_func closure to aggregate grouped entries |
- Returns
- array assoc array
static translitLatin1 |
( |
|
$text | ) |
|
|
static |
transliterates latin1 string to ascii
- Parameters
-
- Returns
- string
unsetBy |
( |
|
$key, |
|
|
|
$values, |
|
|
|
$op = '==' |
|
) |
| |
mark element(s) for deletion where given column has given value(s) element(s) are moved to internal deleted collection pass array for multiple values
operators: == equal, like php === identical, like php !=,<> not equal, like php !== not identical, like php <,>,<=,>= less,greater,less or equal,greater or equal >< between without borders, needs two arguments >=<= between including borders, needs two arguments %= like string, transliterate to ascii,case insensitive *= contains string ^= begins with string $= ends with string ~= regex
- Parameters
-
string | $key | |
mixed | $values | |
| string|callable(mixed,mixed|array),: | bool $op operator to find elements |
- Returns
- int|false number of unsetted elements
get the the value from given key from first element
- Parameters
-
- Returns
- mixed
The documentation for this class was generated from the following file: