__call()
__construct()
__toString()
collect()
compareObjects()
count()
current()
deleteAll()
filterBy()
first()
getObjectsClassName()
getPage()
getPageCount()
getRawArray()
key()
next()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
orderBy()
removeFilter()
removeFilters()
rewind()
valid()
filterObject()
$class_name
$object_keys
$objects
$operators
$previous_result_set
COLLECT_PREFIX
FILTER_PREFIX
ORDER_PREFIX
List of objects on steroids.
Class used for wrapping list of objects into result set with filtering, ordering and paging capabilities.
| author | Tomasz Sawicki (https://github.com/Furgas) |
|---|---|
| package | Common |
__call(string $name, array $arguments) : \kyResultSet
To get available filter methods, call kyObjectType::getAvailableFilterMethods(). To get available order methods, call kyObjectType::getAvailableOrderMethods().
stringMethod name.
arrayMethod arguments.
__construct(\kyObjectBase[] | \kyResultSet $objects, string $class_name, \kyResultSet $previous_result_set)
stringOptional. Class name of objects in this result set.
\kyResultSetOptional result set which was the base of filtering operation producing this result set.
__toString()
Calls __toString method of every object.
collect(string $get_method_name) : array
NOTICE: This method shouldn't be used directly in most cases. Use kyResultSet->collectXXX() instead.
Additional method arguments will be passed as arguments to the get method.
stringName of the method to call on object.
arraycompareObjects(\kyObjectBase $object1, \kyObjectBase $object2, string $get_method_name, bool $asc) : int
NOTICE: Internal helper method for sorting.
stringName of get method to call on each object to compare its values.
boolTrue (default) to sort ascending. False to sort descending.
intcount()
current()
deleteAll()
WARNING: Use carefully!
filterBy(string $get_method_name, array $filter_values) : \kyResultSet
Filtering is done by calling defined get method on all objects and comparing its result with provided filter values. Filter value can be any scalar value (integer, float, string or boolean) or array for special cases. Special cases for filter value: - array('~' "Perl regexp pattern") - running Perl regexp match against object value - array('>', filter_value) - values greater than provided = array('<', filter_value) - values lesser than provided - array('>=', filter_value) - values greater or equal than provided - array('<=', filter_value) - values lesser or equal than provided - array('!=', filter_value) - values other than provided
NOTICE: This method shouldn't be used directly in most cases. Use kyResultSet->filterByXXX(filter_value1, filter_value2) instead. Call kyObjectType::getAvailableFilterMethods() for possible filter methods.
Additional method arguments will be passed as arguments to the get method.
stringName of get method to call on every object for comparing its value with filter values.
arrayList of filter values.
getObjectsClassName() : string
stringgetPage(int $page_number, int $items_per_page) : \kyResultSet
Pass page number and maximum items count per page and it will return new result with items on specified page.
NOTICE: Use the same maximum number of items per page for each page to get the proper behaviour.
intPage number, starting from 1.
intMaximum number of items per page (default 20).
getPageCount(int $items_per_page) : int
intMaximum number of items per page (default 20).
intkey()
next()
offsetExists($offset)
offsetGet($offset)
offsetSet($offset, $value)
offsetUnset($offset)
orderBy(string $get_method_name, bool $asc) : \kyResultSet
Sorting is done by calling defined get method on all objects and using its result to sort objects. NOTICE: This method shouldn't be used directly in most cases. Use kyResultSet->orderByXXX() instead. Call kyObjectType::getAvailableOrderMethods() for possible order methods. WARNING: Calling this method resets internal pointer of objects array.
stringName of get method to call on every object to order based on its value.
boolTrue (default) to sort ascending. False to sort descending.
rewind()
valid()
filterObject(array $filter_values, array $object_values) : bool
arrayFilter values.
arrayObject values.
bool$class_name : string
$object_keys : mixed[]
$operators : string[]
$previous_result_set : \kyResultSet
COLLECT_PREFIX : string
FILTER_PREFIX : string
ORDER_PREFIX : string