1 | <?php |
||
12 | trait ObjectCollectionTrait |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @param callable $callback |
||
17 | * @param array|null $optionalArguments |
||
18 | * @return static |
||
19 | */ |
||
20 | abstract public function find(callable $callback, array $optionalArguments = null); |
||
21 | |||
22 | /** |
||
23 | * @param callable $callback |
||
24 | * @param array|null $optionalArguments |
||
25 | * @return static |
||
26 | */ |
||
27 | abstract public function filter(callable $callback, array $optionalArguments = null); |
||
28 | |||
29 | /** |
||
30 | * @param callable $compareFunction |
||
31 | * @return static |
||
32 | */ |
||
33 | abstract public function sort(callable $compareFunction); |
||
34 | |||
35 | /** |
||
36 | * @param string $className |
||
37 | * |
||
38 | * @return mixed |
||
39 | */ |
||
40 | public function findByType($className) |
||
44 | |||
45 | /** |
||
46 | * @param string $className |
||
47 | * @return static |
||
48 | */ |
||
49 | public function filterByType($className) |
||
53 | |||
54 | /** |
||
55 | * @param string $propertyName |
||
56 | * @param $value |
||
57 | * @param bool $useGetters |
||
58 | * @return static |
||
59 | */ |
||
60 | 1 | public function filterByProperty($propertyName, $value, $useGetters = false) |
|
66 | |||
67 | /** |
||
68 | * @param string $propertyName |
||
69 | * @param $value |
||
70 | * @param bool $useGetters |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 1 | public function findByProperty($propertyName, $value, $useGetters = false) |
|
79 | |||
80 | /** |
||
81 | * @param string $propertyName |
||
82 | * @return static |
||
83 | */ |
||
84 | public function sortByProperty($propertyName) |
||
96 | |||
97 | 1 | private function getPropertyComparator($propertyName, $value, $useGetters) |
|
110 | |||
111 | /** |
||
112 | * Returns array indexed by specified property of collection elements. |
||
113 | * If there is few elements with same property value, last will be used. |
||
114 | * |
||
115 | * @param string $propertyName |
||
116 | * @return array|object[] |
||
117 | */ |
||
118 | public function indexByProperty($propertyName) |
||
129 | } |
||
130 |