RoutesServiceDecorator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A getRoutes() 0 9 2
1
<?php
2
/**
3
 * Copyright (c) 2017
4
 *
5
 * @package   Majima
6
 * @author    David Neustadt <[email protected]>
7
 * @copyright 2017 David Neustadt
8
 * @license   MIT
9
 */
10
11
namespace Majima\PluginBundle\Services;
12
13
use Majima\Services\FluentPdoFactory;
14
use Majima\Services\RoutesService;
15
use Symfony\Component\DependencyInjection\Container;
16
17
/**
18
 * Class RoutesServiceDecorator
19
 * @package Plugins\MajimaGrid\Services
20
 */
21
class RoutesServiceDecorator extends RoutesService
22
{
23
    /**
24
     * @var RoutesService
25
     */
26
    private $service;
27
28
    /**
29
     * @var array
30
     */
31
    private $pluginRoutes = [];
32
33
    /**
34
     * RoutesServiceDecorator constructor.
35
     * @param RoutesService $service
36
     * @param Container $container
37
     * @param FluentPdoFactory $fluentPdo
38
     */
39
    public function __construct($service, Container $container, FluentPdoFactory $fluentPdo)
40
    {
41
        $this->service = $service;
42
        $this->pluginRoutes = $container->hasParameter('majima.plugin.routes') ? $container->getParameter('majima.plugin.routes') : [];
43
44
        parent::__construct($container, $fluentPdo);
45
    }
46
47
    /**
48
     * @return array
49
     */
50
    public function getRoutes()
51
    {
52
        $routes = $this->service->getRoutes();
53
54
        foreach ($this->pluginRoutes as $route) {
55
            array_push($routes, $route);
56
        }
57
58
        return $routes;
59
    }
60
}