Conditions | 4 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
22 | 44 | public function __construct(Tmdb $tmdb, \stdClass $result) |
|
23 | { |
||
24 | 44 | $this->logger = $tmdb->logger; |
|
25 | |||
26 | // Valid input object |
||
27 | 44 | $properties = get_object_vars($this); |
|
28 | 44 | foreach (array_keys($properties) as $property) |
|
29 | { |
||
30 | 44 | if ( ! in_array($property, $this->property_blacklist) && ! property_exists($result, $property)) |
|
31 | { |
||
32 | 2 | throw new NotFoundException($property); |
|
33 | } |
||
34 | } |
||
35 | |||
36 | // Configuration |
||
37 | 42 | $this->conf = $tmdb->getConfiguration(); |
|
38 | 42 | $this->data = $result; |
|
|
|||
39 | 42 | } |
|
40 | |||
42 |
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: