Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
73 | 4 | public function __call($name, $arguments) |
|
74 | { |
||
75 | 4 | $action = substr($name, 0, 3); |
|
76 | 4 | $property = strtolower(substr($name, 3)); |
|
77 | switch ($action) { |
||
78 | 4 | case 'get': |
|
|
|||
79 | 3 | return $this->$property; |
|
80 | break; |
||
81 | |||
82 | 1 | case 'set': |
|
83 | 1 | $this->$property = $arguments[0]; |
|
84 | 1 | break; |
|
85 | } |
||
86 | 1 | return false; |
|
87 | } |
||
88 | } |
||
89 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.