Conditions | 6 |
Paths | 6 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 9 |
Ratio | 34.62 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
17 | public function transform($rRule) |
||
18 | { |
||
19 | 1 | if (preg_match('/'.$this::RRULE_PARAMETER.';TZID=([a-zA-Z_-]+[\/[a-zA-Z_+\-0-9]+]?):([0-9]{8}T[0-9]{6})/', $rRule, $matches)) { |
|
20 | try { |
||
21 | 1 | return \DateTime::createFromFormat('Ymd\THis', $matches[2], new \DateTimeZone($matches[1])); |
|
22 | 1 | } catch (\Exception $e) { |
|
23 | 1 | throw new \InvalidArgumentException(sprintf('Invalid RRULE [%s] option : [%s] with timezone [%s]', $this::RRULE_PARAMETER, $matches[2], $matches[1])); |
|
24 | } |
||
25 | } |
||
26 | |||
27 | 1 | View Code Duplication | if (preg_match('/'.$this::RRULE_PARAMETER.'=([0-9]{8}T[0-9]{6}Z)/', $rRule, $matches)) { |
28 | 1 | return \DateTime::createFromFormat('Ymd\THisZ', $matches[1], new \DateTimeZone('UTC')); |
|
29 | } |
||
30 | |||
31 | 1 | View Code Duplication | if (preg_match('/'.$this::RRULE_PARAMETER.'=([0-9]{8}T[0-9]{6})/', $rRule, $matches)) { |
32 | 1 | return \DateTime::createFromFormat('Ymd\THis', $matches[1]); |
|
33 | } |
||
34 | |||
35 | 1 | View Code Duplication | if (preg_match('/'.$this::RRULE_PARAMETER.'=([0-9]{8})/', $rRule, $matches)) { |
36 | 1 | return \DateTime::createFromFormat('Ymd', $matches[1]); |
|
37 | } |
||
38 | |||
39 | 1 | $this->throwExceptionOnInvalidParameter($rRule, $this::RRULE_PARAMETER); |
|
40 | |||
41 | 1 | return null; |
|
42 | } |
||
43 | } |
||
44 |