1 | <?php |
||
4 | trait CollectionFilterTrait |
||
5 | { |
||
6 | /** |
||
7 | * @param callable|null $filter |
||
8 | * @param int $flag (only for php version >= 5.6) |
||
9 | * @return $this |
||
|
|||
10 | */ |
||
11 | 1 | public function filter(callable $filter = null, $flag = 0) |
|
24 | |||
25 | /** |
||
26 | * Executes the callback for every value. |
||
27 | * Returns a collection with the result of each callback call. |
||
28 | * If the callback returns nothing, the returned collection will contain same values as the original ones. |
||
29 | * |
||
30 | * @param callable $callback |
||
31 | * @param array $args |
||
32 | * @return $this |
||
33 | */ |
||
34 | 3 | public function each(callable $callback, array $args = []) |
|
43 | |||
44 | /** |
||
45 | * Executes the callback for every value. |
||
46 | * Returns false if the callback returns once a falsy value. |
||
47 | * |
||
48 | * @param callable $callback |
||
49 | * @return bool |
||
50 | */ |
||
51 | 2 | public function assert(callable $callback) |
|
60 | |||
61 | /** |
||
62 | * Extracts the sequence of elements. |
||
63 | * Starts at index $startIndex and stop after $length keys. |
||
64 | * |
||
65 | * @param int $startIndex |
||
66 | * @param int $length |
||
67 | * @param bool $areKeysPreserved |
||
68 | * @return mixed |
||
69 | */ |
||
70 | 3 | public function extract($startIndex, $length = 0, $areKeysPreserved = true) |
|
76 | |||
77 | /** |
||
78 | * @param int $length |
||
79 | * @return $this |
||
80 | */ |
||
81 | 1 | public function rand($length = 1) |
|
92 | } |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.