Test Failed
Pull Request — master (#3)
by Бабичев
01:54
created

PatternRule::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.1852

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 3
cts 9
cp 0.3333
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 3
crap 3.1852
1
<?php
2
3
namespace Bavix\Router\Rules;
4
5
use Bavix\Exceptions\NotFound\Path;
6
use Bavix\Router\Rule;
7
8
class PatternRule extends Rule
9
{
10
11
    /**
12
     * PatternRule constructor.
13
     *
14
     * @param string $key
15
     * @param iterable $storage
16
     * @param Rule|null $parent
17
     */
18 1
    public function __construct(string $key, $storage, ?Rule $parent = null)
19
    {
20 1
        parent::__construct($key, $storage, $parent);
21
22 1
        if (!$this->path) {
23
            throw new Path(
24
                \sprintf(
25
                    'No `%s` option found for class `%s` on `%s` route',
26
                    'path',
27
                    __CLASS__,
28
                    $key
29
                )
30
            );
31
        }
32 1
    }
33
34
}
35