Conditions | 4 |
Paths | 6 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
16 | 2 | public function setNotes($value) |
|
17 | { |
||
18 | 2 | $this->values['notes'] = []; |
|
|
|||
19 | |||
20 | 2 | if ($value instanceof Note) { |
|
21 | 2 | $value = [$value]; |
|
22 | 2 | } |
|
23 | |||
24 | 2 | foreach ($value as $note) { |
|
25 | 2 | if ($note instanceof Note) { |
|
26 | 2 | $note = $note->getValues(); |
|
27 | 2 | } |
|
28 | |||
29 | 2 | $this->values['notes'][] = $note; |
|
30 | 2 | } |
|
31 | |||
32 | 2 | return $this; |
|
33 | } |
||
34 | } |
||
35 |
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: