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 | abstract public function toArray(); |
||
30 | |||
31 | /** |
||
32 | * @param callable $compareFunction |
||
33 | * @return static |
||
34 | */ |
||
35 | abstract public function sort(callable $compareFunction); |
||
36 | |||
37 | /** |
||
38 | * @param string $className |
||
39 | * |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function findByType($className) |
||
46 | |||
47 | /** |
||
48 | * @param string $className |
||
49 | * @return static |
||
50 | */ |
||
51 | public function filterByType($className) |
||
55 | |||
56 | /** |
||
57 | * @param string $propertyName |
||
58 | * @param $value |
||
59 | * @param bool $useGetters |
||
60 | * @return static |
||
61 | */ |
||
62 | 1 | public function filterByProperty($propertyName, $value, $useGetters = false) |
|
68 | |||
69 | /** |
||
70 | * @param string $propertyName |
||
71 | * @param $value |
||
72 | * @param bool $useGetters |
||
73 | * @return mixed |
||
74 | */ |
||
75 | 1 | public function findByProperty($propertyName, $value, $useGetters = false) |
|
81 | |||
82 | /** |
||
83 | * @param string $propertyName |
||
84 | * @return static |
||
85 | */ |
||
86 | public function sortByProperty($propertyName) |
||
98 | |||
99 | 1 | private function getPropertyComparator($propertyName, $value, $useGetters) |
|
112 | |||
113 | /** |
||
114 | * Returns array indexed by specified property of collection elements. |
||
115 | * If there is few elements with same property value, last will be used. |
||
116 | * |
||
117 | * @param string $propertyName |
||
118 | * @return array|object[] |
||
119 | */ |
||
120 | public function indexByProperty($propertyName) |
||
131 | } |
||
132 |