Passed
Branch factorize (4cfa74)
by Samuel
01:51
created

UntilTransformer::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Recurrence\Rrule\Transformer;
4
5
use Recurrence\Rrule\Extractor\UntilExtractor;
6
use Recurrence\Model\Exception\InvalidRruleException;
7
8
/**
9
 * Class UntilTransformer
10
 * @package Recurrence\Rrule\Transformer
11
 */
12
class UntilTransformer extends DtStartTransformer
13
{
14
    /**
15
     * @param array $values
16
     * @return \DateTime
17
     * @throws InvalidRruleException
18
     */
19
    public function transform(array $values)
20
    {
21 1
        $this->validate($values);
22
23
        try {
24 1
            return parent::transform($values);
25 1
        } catch (\Exception $e) {
26 1
            throw new InvalidRruleException(UntilExtractor::RRULE_PARAMETER, (string) $values[0]);
27
        }
28
    }
29
30
    /**
31
     * @param array $values
32
     * @throws InvalidRruleException
33
     */
34
    protected function validate(array $values)
35
    {
36 1
        if (!isset($values[0])) {
37 1
            throw new InvalidRruleException(UntilExtractor::RRULE_PARAMETER);
38
        }
39 1
    }
40
}
41