Passed
Push — master ( 2c1367...72194f )
by Alexey
03:21
created

ProcessingRouteCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 30.43%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 62
ccs 7
cts 23
cp 0.3043
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A addGroup() 0 6 1
A addRoute() 0 6 1
A all() 0 4 1
A findByName() 0 4 1
1
<?php declare(strict_types = 1);
2
3
namespace Venta\Routing;
4
5
use Venta\Contracts\Routing\Route as RouteContract;
6
use Venta\Contracts\Routing\RouteCollection as RouteCollectionContract;
7
use Venta\Contracts\Routing\RouteGroup as RouteGroupContract;
8
use Venta\Contracts\Routing\RouteProcessor;
9
10
/**
11
 * Class ProcessingRouteCollection
12
 *
13
 * @package Venta\Routing
14
 */
15
final class ProcessingRouteCollection implements RouteCollectionContract
16
{
17
18
    /**
19
     * @var RouteProcessor
20
     */
21
    private $processor;
22
23
    /**
24
     * @var RouteCollectionContract
25
     */
26
    private $routes;
27
28
    /**
29
     * ProcessingRouteCollection constructor.
30
     *
31
     * @param RouteCollectionContract $routes
32
     * @param RouteProcessor $processor
33
     */
34 2
    public function __construct(RouteCollectionContract $routes, RouteProcessor $processor)
35
    {
36 2
        $this->routes = $routes;
37 2
        $this->processor = $processor;
38 2
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function addGroup(RouteGroupContract $group): RouteCollectionContract
44
    {
45
        $this->routes->addGroup($group);
46
47
        return $this;
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53 1
    public function addRoute(RouteContract $route): RouteCollectionContract
54
    {
55 1
        $this->routes->addRoute($this->processor->process($route));
56
57 1
        return $this;
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    public function all(): array
64
    {
65
        return $this->routes->all();
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    public function findByName(string $routeName)
72
    {
73
        return $this->routes->findByName($routeName);
74
    }
75
76
}