UntilTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 4 2
A transform() 0 8 2
1
<?php
2
3
namespace Recurrence\Rrule\Transformer;
4
5
use Recurrence\Rrule\Extractor\UntilExtractor;
6
use Recurrence\Model\Exception\InvalidRruleException;
7
8
class UntilTransformer extends DtStartTransformer
9
{
10
    /**
11
     * @throws InvalidRruleException
12
     */
13
    public function transform(array $values): \DateTime
14
    {
15 1
        $this->validate($values);
16
17
        try {
18 1
            return parent::transform($values);
19 1
        } catch (\Exception $e) {
20 1
            throw new InvalidRruleException(UntilExtractor::RRULE_PARAMETER, (string) $values[0]);
21
        }
22
    }
23
24
    /**
25
     * @throws InvalidRruleException
26
     */
27
    protected function validate(array $values): void
28
    {
29 1
        if (!isset($values[0])) {
30 1
            throw new InvalidRruleException(UntilExtractor::RRULE_PARAMETER);
31
        }
32 1
    }
33
}
34