Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function __call($name, $values) |
||
32 | { |
||
33 | foreach ($this->register() as $type => $alias) { |
||
34 | if ($alias == $name) { |
||
35 | // call that method |
||
36 | return $this->type = new $type( |
||
|
|||
37 | $this->toArray($values) |
||
38 | ); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | throw new \Exception('The called method is not defined or unsupported'); |
||
43 | } |
||
44 | } |
||
45 |
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: