CountTransformer::validate()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 4
nc 2
nop 1
crap 4
1
<?php
2
3
namespace Recurrence\Rrule\Transformer;
4
5
use Recurrence\Rrule\Extractor\CountExtractor;
6
use Recurrence\Model\Exception\InvalidRruleException;
7
8
class CountTransformer implements RruleTransformerInterface
9
{
10
    /**
11
     * @throws InvalidRruleException
12
     */
13
    public function transform(array $values): int
14
    {
15 1
        $this->validate($values);
16
17 1
        return (int) $values[0];
18
    }
19
20
    /**
21
     * @throws InvalidRruleException
22
     */
23
    protected function validate(array $values): void
24
    {
25 1
        if (!isset($values[0]) || !is_numeric($values[0])) {
26 1
            throw new InvalidRruleException(CountExtractor::RRULE_PARAMETER, ((isset($values[0])) ? (string) $values[0] : ''));
27
        }
28 1
    }
29
}
30