Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function wrapInResource($value) |
||
17 | { |
||
18 | if (!$this->resource) { |
||
19 | throw new Exception("You must first set a resource class"); |
||
20 | } |
||
21 | |||
22 | if ($value instanceof Model) { |
||
23 | $resource_class = $this->resource; |
||
24 | return $resource_class::make($value); |
||
25 | } |
||
26 | |||
27 | if ($this->resource_collection) { |
||
28 | $resource_class = $this->resource_collection; |
||
29 | return $resource_class::make($value); |
||
30 | } |
||
31 | |||
32 | $resource_class = $this->resource; |
||
33 | |||
34 | return $resource_class::collection($value); |
||
35 | } |
||
36 | } |
||
37 |
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: