Conditions | 5 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
19 | public function transform(array $values) |
||
20 | { |
||
21 | 1 | $this->validate($values); |
|
22 | |||
23 | 1 | $dtStart = null; |
|
|
|||
24 | |||
25 | 1 | if (count($values) == 2 && substr($values[1], -1) == 'Z') { |
|
26 | 1 | $dtStart = \DateTime::createFromFormat('Ymd\THis\Z', $values[0], new \DateTimeZone('UTC')); |
|
27 | 1 | } else if (count($values) == 2) { |
|
28 | 1 | $dtStart = \DateTime::createFromFormat('Ymd\THis', $values[0]); |
|
29 | } else { |
||
30 | 1 | $dtStart = \DateTime::createFromFormat('Ymd', $values[0]); |
|
31 | } |
||
32 | |||
33 | 1 | if (!$dtStart) { |
|
34 | 1 | throw new InvalidRruleException(DtStartExtractor::RRULE_PARAMETER, (string) $values[0]); |
|
35 | } |
||
36 | |||
37 | 1 | return $dtStart; |
|
38 | } |
||
39 | |||
51 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.