1 | <?php |
||
25 | class QueryObject extends Select implements QueryObjectInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var RepositoryInterface |
||
30 | */ |
||
31 | protected $repository; |
||
32 | |||
33 | /** |
||
34 | * For triggering events |
||
35 | */ |
||
36 | use SelectEventTriggers; |
||
37 | |||
38 | /** |
||
39 | * QueryObject has a repository as a dependency. |
||
40 | * |
||
41 | * @param RepositoryInterface $repository |
||
42 | */ |
||
43 | 12 | public function __construct(RepositoryInterface $repository) |
|
52 | |||
53 | /** |
||
54 | * Retrieve all records matching this select query |
||
55 | * |
||
56 | * @return \Slick\Database\RecordList |
||
57 | */ |
||
58 | 6 | public function all() |
|
94 | |||
95 | /** |
||
96 | * Handles collection add event and updates the cache |
||
97 | * |
||
98 | * @param EntityAdded $event |
||
99 | */ |
||
100 | public function updateCollection(EntityAdded $event) |
||
108 | |||
109 | /** |
||
110 | * Retrieve first record matching this select query |
||
111 | * |
||
112 | * @return EntityInterface|null |
||
113 | */ |
||
114 | 2 | public function first() |
|
142 | |||
143 | /** |
||
144 | * Gets the id for this query |
||
145 | * |
||
146 | * @param QueryObjectInterface $query |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | 8 | protected function getId(QueryObjectInterface $query) |
|
157 | |||
158 | /** |
||
159 | * Registers every entity in collection to the repository identity map |
||
160 | * |
||
161 | * @param EntityCollection $collection |
||
162 | * |
||
163 | * @return self |
||
164 | */ |
||
165 | 6 | protected function updateIdentityMap(EntityCollection $collection) |
|
177 | |||
178 | /** |
||
179 | * Returns the repository that is using this query object |
||
180 | * |
||
181 | * @return RepositoryInterface |
||
182 | */ |
||
183 | 10 | public function getRepository() |
|
187 | |||
188 | /** |
||
189 | * Gets current entity class name |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | 6 | public function getEntityClassName() |
|
197 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.