CountTransformer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 4 4
A transform() 0 5 1
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