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