Conditions | 6 |
Paths | 13 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
25 | protected function collectResource($resource) |
||
26 | { |
||
27 | if ($resource instanceof MissingValue) { |
||
28 | return $resource; |
||
29 | } |
||
30 | |||
31 | $collects = $this->collects(); |
||
32 | |||
33 | $this->collection = $collects && !$resource->first() instanceof $collects |
||
34 | ? $resource->mapInto($collects) |
||
35 | : $resource->toBase(); |
||
36 | |||
37 | if ($resource instanceof AbstractPaginator) { |
||
38 | $resource->setCollection($this->collection); |
||
39 | return $resource; |
||
40 | } |
||
41 | if ($resource instanceof PaginationResult) { |
||
42 | $resource->records = $this->collection; |
||
43 | return $resource; |
||
44 | } |
||
45 | |||
46 | return $this->collection; |
||
47 | } |
||
48 | } |
||
49 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: