Conditions | 6 |
Paths | 18 |
Total Lines | 29 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 6.0045 |
Changes | 0 |
1 | <?php |
||
14 | 4 | public function __construct($options = []) |
|
15 | { |
||
16 | 4 | if (isset($options['value'])) { |
|
17 | 4 | $options['propertyName'] = $options['value']; |
|
18 | 4 | unset($options['value']); |
|
19 | 2 | } |
|
20 | |||
21 | 4 | $this->priority = 10; |
|
22 | |||
23 | $default = [ |
||
24 | 4 | 'priority' => 10, |
|
25 | 2 | ]; |
|
26 | |||
27 | 4 | foreach ($default as $key => $value) { |
|
28 | 4 | if (isset($options[$key]) == false) { |
|
|
|||
29 | 4 | $options[$key] = $value; |
|
30 | 2 | } |
|
31 | 2 | } |
|
32 | |||
33 | 4 | foreach ($options as $key => $value) { |
|
34 | 4 | if (!property_exists($this, $key)) { |
|
35 | throw new \InvalidArgumentException(sprintf('Property "%s" does not exist', $key)); |
||
36 | } |
||
37 | |||
38 | 4 | $this->$key = $value; |
|
39 | 2 | } |
|
40 | |||
41 | 4 | $this->options = $options; |
|
42 | 4 | } |
|
43 | |||
54 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.