Source of file CollectionReadInterface.php
Size: 2,963 Bytes - Last Modified: 2016-07-22T15:31:35+00:00
/home/travis/build/Nayjest/Collection/src/CollectionReadInterface.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | <?php namespace Nayjest\Collection; use Countable; use IteratorAggregate; /** * CollectionReadInterface describes methods of immutable collection. */ interface CollectionReadInterface extends IteratorAggregate, Countable { /** * Returns collection items in array. * * @return array */ public function toArray(); /** * Returns true if collection is empty. * * @return bool */ public function isEmpty(); /** * Returns first item of the collection or null if collection is empty. * * @return mixed|null */ public function first(); /** * Checks that collections contains target item. * * @param $item * * @return bool */ public function contains($item); /** * Iterates over each value in the <b>collection</b> * passing them to the <b>callback</b> function. * If the <b>callback</b> function returns true, the * current value from <b>collection</b> is returned into * the result collection. * * @param callable $callback the callback function to use * @param array|null $optionalArguments [optional] additional arguments passed to callback * * @return CollectionReadInterface|static filtered collection */ public function filter(callable $callback, array $optionalArguments = null); /** * Iterates over each value in the <b>collection</b> * passing them to the <b>callback</b> function. * If the <b>callback</b> function returns true, the * current value from <b>collection</b> is returned. * * @param callable $callback the callback function to use * @param array|null $optionalArguments [optional] additional arguments passed to callback * * @return mixed|FALSE collection item or false if item is not found. */ public function find(callable $callback, array $optionalArguments = null); /** * @param callable $callback the callback function to use * @param array|null $optionalArguments [optional] additional arguments passed to callback * @return CollectionReadInterface|static */ public function map(callable $callback, array $optionalArguments = null); /** * @param callable $compareFunction * @return CollectionReadInterface|static */ public function sort(callable $compareFunction); /** * Returns random collection element or NULL for empty collection. * @return mixed|null */ public function random(); /** * @param $item * @return CollectionReadInterface|static */ public function beforeItem($item); /** * @param $item * @return CollectionReadInterface|static */ public function afterItem($item); /** * Returns true if collection implements CollectionWriteInterface. * * @return bool */ public function isWritable(); } |