1 | <?php |
||
19 | class MetaItemCollection extends CollectionBase implements CollectionContract |
||
20 | { |
||
21 | /** |
||
22 | * Fully qualified class name to use when creating new items via magic methods. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected static $item_class; |
||
27 | |||
28 | /** |
||
29 | * The default tag name to use when using magic methods. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $default_tag = 'default'; |
||
34 | |||
35 | /** |
||
36 | * Keys of the models that the collection was constructed with. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $original_model_keys = []; |
||
41 | |||
42 | /** |
||
43 | * MetaItemCollection constructor. |
||
44 | * |
||
45 | * @param array $items |
||
46 | */ |
||
47 | 29 | public function __construct($items = []) |
|
57 | |||
58 | /** |
||
59 | * Sets the default tag on any 'tag-less' items. |
||
60 | * |
||
61 | * @param array $items |
||
62 | */ |
||
63 | 29 | protected function setTags(array $items) |
|
73 | |||
74 | /** |
||
75 | * Get the array of primary keys. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | 29 | public function modelKeys() |
|
91 | |||
92 | /** |
||
93 | * Get the array of primary keys the collection was constructed with. |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | 8 | public function originalModelKeys() |
|
101 | |||
102 | /** |
||
103 | * Add an item to the collection. |
||
104 | * |
||
105 | * @param mixed $item |
||
106 | * @return $this |
||
107 | * @throws InvalidArgumentException |
||
108 | */ |
||
109 | 11 | public function add($item) |
|
127 | |||
128 | /** |
||
129 | * Get the collection key form an item key and tag. |
||
130 | * |
||
131 | * @param mixed $key |
||
132 | * @param null $tag |
||
133 | * @return mixed |
||
134 | */ |
||
135 | 20 | public function findItem($key, $tag = null) |
|
147 | |||
148 | /** |
||
149 | * Set deletion listeners on an array of items. |
||
150 | * |
||
151 | * @param array $items |
||
152 | */ |
||
153 | 29 | protected function observeDeletions(array $items) |
|
161 | |||
162 | /** |
||
163 | * Set a deletion listener on an item. |
||
164 | * |
||
165 | * @param \BoxedCode\Eloquent\Meta\Contracts\MetaItem $item |
||
166 | */ |
||
167 | protected function observeDeletion(MetaItemContract $item) |
||
177 | |||
178 | /** |
||
179 | * Get the class name that will be used to construct new |
||
180 | * items via the magic methods. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | 1 | public static function getMetaItemClass() |
|
188 | |||
189 | /** |
||
190 | * Set the class name that will be used to construct new |
||
191 | * items via the magic methods. |
||
192 | * |
||
193 | * @param $class |
||
194 | */ |
||
195 | 10 | public static function setMetaItemClass($class) |
|
203 | |||
204 | /** |
||
205 | * Get the default tag name that will be used to construct new |
||
206 | * items via the magic methods. |
||
207 | * |
||
208 | * @return string |
||
209 | */ |
||
210 | 1 | public function getDefaultTag() |
|
214 | |||
215 | /** |
||
216 | * Set the default tag name that will be used to construct new |
||
217 | * items via the magic methods. |
||
218 | * |
||
219 | * @param $name |
||
220 | * @return $this |
||
221 | */ |
||
222 | 2 | public function setDefaultTag($name) |
|
228 | |||
229 | /** |
||
230 | * Resolve calls to filter the collection by item attributes. |
||
231 | * |
||
232 | * @param string $name |
||
233 | * @param array $arguments |
||
234 | * @return static |
||
235 | */ |
||
236 | 22 | public function __call($name, $arguments) |
|
244 | |||
245 | /** |
||
246 | * Resolve calls to check whether an item with a specific key name exists. |
||
247 | * |
||
248 | * @param $name |
||
249 | * @return bool |
||
250 | */ |
||
251 | 3 | public function __isset($name) |
|
255 | |||
256 | /** |
||
257 | * Resolve calls to unset an item with a specific key name. |
||
258 | * |
||
259 | * @param $name |
||
260 | */ |
||
261 | 2 | public function __unset($name) |
|
269 | |||
270 | /** |
||
271 | * Resolve calls to get an item with a specific key name or a |
||
272 | * collection of items with a specific tag name. |
||
273 | * |
||
274 | * @param $name |
||
275 | * @return mixed |
||
276 | */ |
||
277 | 7 | public function __get($name) |
|
291 | |||
292 | /** |
||
293 | * Resolve calls to set a new item to the collection or |
||
294 | * update an existing key. |
||
295 | * |
||
296 | * @param $name |
||
297 | * @param $value |
||
298 | */ |
||
299 | 3 | public function __set($name, $value) |
|
317 | } |
||
318 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: