Passed
Push — master ( ecadea...14db22 )
by Damien
03:21
created

RoutingAnnotationLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A load() 0 8 2
1
<?php
2
3
namespace DH\DoctrineAuditBundle\Routing;
4
5
use DH\DoctrineAuditBundle\Controller\ViewerController;
6
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
7
use Symfony\Component\Config\Loader\Loader;
8
use Symfony\Component\Config\Loader\LoaderInterface;
9
use Symfony\Component\Routing\RouteCollection;
10
11
class RoutingAnnotationLoader extends Loader implements LoaderInterface
12
{
13
    /**
14
     * @var AnnotatedRouteControllerLoader
15
     */
16
    private $annotationLoader;
17
18
    /**
19
     * @var array
20
     */
21
    private $configuration;
22
23
    public function load($resource, ?string $type = null): RouteCollection
24
    {
25
        $routeCollection = new RouteCollection();
26
        if (true === $this->configuration['enabled_viewer']) {
27
            $routeCollection = $this->annotationLoader->load(ViewerController::class);
28
        }
29
30
        return $routeCollection;
31
    }
32
33
    public function supports($resource, ?string $type = null): bool
34
    {
35
        return 'audit_loader' === $type;
36
    }
37
}
38