Conditions | 2 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | 3 | function __construct($value) |
|
|
|||
15 | { |
||
16 | 3 | $ref = new \ReflectionObject($this); |
|
17 | 3 | $consts = $ref->getConstants(); |
|
18 | 3 | if (! in_array($value, $consts, true)) { |
|
19 | 1 | throw new \InvalidArgumentException( |
|
20 | 1 | 'value must be ' . implode(',', $consts) . ". but $value passed." |
|
21 | 1 | ); |
|
22 | } |
||
23 | 2 | $this->scalar = $value; |
|
24 | 2 | } |
|
25 | |||
48 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.