Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 5 | ||
Bugs | 1 | Features | 2 |
1 | <?php |
||
37 | 78 | public function setCopy($copy = null) |
|
38 | { |
||
39 | 78 | if (is_null($copy)) { |
|
40 | /** @noinspection PhpUndefinedFieldInspection */ |
||
41 | 15 | $this->copy = null; |
|
|
|||
42 | 15 | } |
|
43 | 78 | elseif (!is_scalar($copy)) { |
|
44 | 15 | throw InvalidArgumentException::create( |
|
45 | 15 | 'string (or scalar)', |
|
46 | $copy |
||
47 | 15 | ); |
|
48 | } |
||
49 | else { |
||
50 | /** @noinspection PhpUndefinedFieldInspection */ |
||
51 | 63 | $this->copy = (string) $copy; |
|
52 | } |
||
53 | 63 | return $this; |
|
54 | } |
||
55 | |||
67 |
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: