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