| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | 120 | public function __construct($config) |
|
| 11 | { |
||
| 12 | 120 | if (is_array($config)) { |
|
| 13 | 117 | $this->path = $config['path']; |
|
| 14 | 117 | $this->generate = $config['generate']; |
|
| 15 | 117 | $this->namespace = $config['namespace'] ?? $config['path']; |
|
|
|
|||
| 16 | |||
| 17 | 117 | return; |
|
| 18 | } |
||
| 19 | 5 | $this->path = $config; |
|
| 20 | 5 | $this->generate = (bool) $config; |
|
| 21 | 5 | $this->namespace = $config; |
|
| 22 | 5 | } |
|
| 23 | |||
| 39 |
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: