BearFramework\DataList

Base class for lists.
BearFramework\DataList implements ArrayAccessIteratorTraversableCountable {

    
/* Methods */
    
public __construct ( [ array|iterable|callback $dataSource ] )
    public 
self concat ( array|iterable $list )
    public 
int count void )
    public 
self filter ( callable $callback )
    public 
self filterBy string $property mixed $value [, string $operator 'equal' ] )
    public 
object|null get int $index )
    public 
object|null getFirst void )
    public 
object|null getLast void )
    public 
object|null getRandom void )
    public 
self map ( callable $callback )
    public 
object|null pop void )
    public 
self push object|array $object )
    public 
self reverse void )
    public 
object|null shift void )
    public 
self shuffle void )
    public 
mixed slice int $offset [, int $length ] )
    public 
mixed sliceProperties ( array $properties )
    public 
self sort ( callable $callback )
    public 
self sortBy string $property [, string $order 'asc' ] )
    public array 
toArray void )
    public 
string toJSON void )
    public 
self unshift object|array $object )

}
Methods
public __construct ( [ array|iterable|callback $dataSource ] )
Constructs a new data list.
public self concat ( array|iterable $list )
Appends the items of the list provided to the current list.
public int count ( void )
Returns the number of items in the list.
public self filter ( callable $callback )
Filters the elements of the list using a callback function.
public self filterBy ( string $property , mixed $value [, string $operator = 'equal' ] )
Filters the elements of the list by specific property value.
public object|null get ( int $index )
Returns the object at the index specified or null if not found.
public object|null getFirst ( void )
Returns the first object or null if not found.
public object|null getLast ( void )
Returns the last object or null if not found.
public object|null getRandom ( void )
Returns a random object from the list or null if the list is empty.
public self map ( callable $callback )
Applies the callback to the objects of the list.
public object|null pop ( void )
Pops an object off the end of the list.
public self push ( object|array $object )
Pushes an object onto the end of the list.
public self reverse ( void )
Reverses the order of the objects in the list.
public object|null shift ( void )
Shift an object off the beginning of the list.
public self shuffle ( void )
Randomly reorders the objects in the list.
public mixed slice ( int $offset [, int $length ] )
Extract a slice of the list.
public mixed sliceProperties ( array $properties )
Returns a new list of object that contain only the specified properties of the objects in the current list.
public self sort ( callable $callback )
Sorts the elements of the list using a callback function.
public self sortBy ( string $property [, string $order = 'asc' ] )
Sorts the elements of the list by specific property.
public array toArray ( void )
Returns the list data converted as an array.
public string toJSON ( void )
Returns the list data converted as JSON.
public self unshift ( object|array $object )
Prepends an object to the beginning of the list.
Details
Location: ~/src/DataList.php
The information on this page is created for version 1.1 of Bear Framework and may not be applicable for other versions of the framework.