Passed
Push — master ( c2e69f...e5bfaf )
by Samuel
43s
created

CountTransformer::transform()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 13
loc 13
ccs 5
cts 5
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Recurrence\RruleTransformer;
4
5
/**
6
 * Class CountTransformer
7
 * @package Recurrence\RruleTransformer
8
 */
9 View Code Duplication
class CountTransformer implements TransformerInterface
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @param string $rRule
13
     * @return integer
14
     */
15
    public function transform($rRule)
16
    {
17 1
        if (preg_match('/COUNT=([0-9]+)/', $rRule, $matches)) {
18 1
            return (int) $matches[1];
19
        }
20
21
        // If there is an INTERVAL option but transformer was not able to get it, assume it was an invalid option
22 1
        if (preg_match('/COUNT=/', $rRule, $matches)) {
23 1
            throw new \InvalidArgumentException('RRULE invalid [COUNT] option');
24
        }
25
26 1
        return null;
27
    }
28
}
29