GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#8)
by Jean-David
08:59
created

M6WebApiExceptionExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 1
cbo 5
dl 0
loc 72
ccs 29
cts 29
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 4 1
A load() 0 8 1
A loadExceptionManager() 0 12 1
B loadExceptionListener() 0 24 1
1
<?php
2
3
namespace M6Web\Bundle\ApiExceptionBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
/**
11
 * This is the class that loads and manages your bundle configuration
12
 */
13
class M6WebApiExceptionExtension extends Extension
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    public function load(array $configs, ContainerBuilder $container)
19
    {
20 1
        $configuration = new Configuration();
21 1
        $config = $this->processConfiguration($configuration, $configs);
22
23 1
        $this->loadExceptionManager($container, $config);
24 1
        $this->loadExceptionListener($container, $config);
25 1
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getAlias()
31
    {
32 1
        return 'm6web_api_exception';
33
    }
34
35
    /**
36
     * load service exception manager
37
     *
38
     * @param ContainerBuilder $container
39
     * @param array            $config
40
     */
41
    protected function loadExceptionManager(ContainerBuilder $container, array $config)
42
    {
43 1
        $definition = new Definition(
44 1
            'M6Web\Bundle\ApiExceptionBundle\Manager\ExceptionManager',
45
            [
46 1
                $config['default'],
47 1
                $config['exceptions'],
48
            ]
49 1
        );
50
51 1
        $container->setDefinition($this->getAlias().'.manager.exception', $definition);
52 1
    }
53
54
    /**
55
     * load service exception listener
56
     *
57
     * @param ContainerBuilder $container
58
     * @param array            $config
59
     */
60
    protected function loadExceptionListener(ContainerBuilder $container, array $config)
61
    {
62 1
        $definition = new Definition(
63 1
            'M6Web\Bundle\ApiExceptionBundle\EventListener\ExceptionListener',
64
            [
65 1
                new Reference('kernel'),
66 1
                new Reference($this->getAlias().'.manager.exception'),
67 1
                $config['match_all'],
68 1
                $config['default'],
69 1
                $config['stack_trace'],
70
            ]
71 1
        );
72
73 1
        $definition->addTag(
74 1
            'kernel.event_listener',
75
            [
76 1
                'event' => 'kernel.exception',
77 1
                'method' => 'onKernelException',
78
                'priority' => '-100' // as the setresponse stop the exception propagation, this listener has to pass in last position
79 1
            ]
80 1
        );
81
82 1
        $container->setDefinition($this->getAlias().'.listener.exception', $definition);
83 1
    }
84
}
85