Conditions | 9 |
Paths | 8 |
Total Lines | 25 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 9.0101 |
Changes | 0 |
1 | <?php |
||
14 | 21 | public function validateConfig($name, &$value) |
|
15 | { |
||
16 | switch ($name) { |
||
17 | 21 | case 'format': |
|
18 | 11 | if ((!is_string($value)) || ($value === '')) { |
|
19 | 10 | $value = null; |
|
20 | 10 | } |
|
21 | 11 | break; |
|
22 | 21 | case 'default': |
|
23 | 21 | if ($value === null) { |
|
24 | 3 | if (!$this->getConfig('nullable')) { |
|
25 | 1 | $value = new \DateTime(); |
|
26 | 1 | } |
|
27 | 21 | } elseif (is_string($value)) { |
|
28 | 15 | $value = new \DateTime($value); |
|
29 | 18 | } elseif (!($value instanceof \DateTime)) { |
|
30 | return false; |
||
31 | } |
||
32 | 21 | break; |
|
33 | 21 | default: |
|
34 | 21 | return parent::validateConfig($name, $value); |
|
35 | break; |
||
|
|||
36 | 21 | } |
|
37 | 21 | return true; |
|
38 | } |
||
39 | |||
91 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.