Route::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 8
nop 1
dl 0
loc 10
ccs 6
cts 7
cp 0.8571
crap 4.0466
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiistack\Routing\Annotation;
6
7
/**
8
 * Class Route
9
 * @package Yiistack\Routing\Annotation
10
 */
11
abstract class Route implements RouteAnnotationInterface
12
{
13
    /**
14
     * @var mixed|string
15
     * @psalm-suppress PropertyNotSetInConstructor
16
     */
17
    protected string $route;
18
19
    /**
20
     * @var array
21
     * @psalm-suppress PropertyNotSetInConstructor
22
     */
23
    protected array $methods;
24
25
    /**
26
     * @var array
27
     * @psalm-suppress PropertyNotSetInConstructor
28
     */
29
    protected array $middlewares;
30
31 1
    public function __construct(array $values)
32
    {
33 1
        if (isset($values['value'])) {
34 1
            $this->route = $values['value'];
35
        }
36 1
        if (isset($values['middlewares'])) {
37
            $this->middlewares = $values['middlewares'];
38
        }
39 1
        if (isset($values['methods'])) {
40 1
            $this->methods = $values['methods'];
41
        }
42 1
    }
43
44 1
    public function getRoute(): string
45
    {
46 1
        return $this->route;
47
    }
48
49 1
    public function getMethods(): array
50
    {
51 1
        return $this->methods;
52
    }
53
54
    public function getMiddlewares(): array
55
    {
56
        return $this->middlewares;
57
    }
58
}
59