| Conditions | 6 |
| Paths | 4 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 42 | 36 | private function buildFromData($data) |
|
| 43 | { |
||
| 44 | 36 | foreach ($this->dto->getDefault() as $key => $value) { |
|
| 45 | 34 | if (is_object($data) && isset($data->{$key})) { |
|
| 46 | 6 | $this->dto[$key] = $data->{$key}; |
|
| 47 | 34 | } else if (is_array($data) && isset($data[$key])) { |
|
| 48 | 13 | $this->dto[$key] = $data[$key]; |
|
| 49 | } else { |
||
| 50 | 34 | $this->dto[$key] = $value; |
|
| 51 | } |
||
| 52 | } |
||
| 53 | 36 | } |
|
| 54 | |||
| 72 | } |
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: