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
Push — master ( 8adfc3...aede48 )
by Pascal
9s
created

SaikootauApiExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 80
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A configureResponseListenerDefaultContentType() 0 4 1
A loadConfiguration() 0 5 1
A loadServices() 0 4 1
A load() 0 8 1
A configureErrorResponseListener() 0 4 1
A getConfiguration() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saikootau\ApiBundle\DependencyInjection;
6
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\Extension\Extension;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11
12
class SaikootauApiExtension extends Extension
13
{
14
    private const SERVICE_EXCEPTION_RESPONSE_LISTENER = 'saikootau_api.event.listener.exception_response';
15
    private const SERVICE_RESOURCE_RESPONSE_LISTENER = 'saikootau_api.event.listener.resource_response';
16
17
    /**
18
     * Return an instance of the bundles configuration class.
19
     *
20
     * @param array            $config
21
     * @param ContainerBuilder $container
22
     *
23
     * @return Configuration
24
     */
25 1
    public function getConfiguration(array $config, ContainerBuilder $container): Configuration
26
    {
27 1
        return new Configuration();
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function load(array $configs, ContainerBuilder $container): void
34
    {
35 1
        $this->loadServices($container);
36
37 1
        $configs = $this->loadConfiguration($configs, $container);
38 1
        $this->configureResponseListenerDefaultContentType(self::SERVICE_EXCEPTION_RESPONSE_LISTENER, $configs, $container);
39 1
        $this->configureResponseListenerDefaultContentType(self::SERVICE_RESOURCE_RESPONSE_LISTENER, $configs, $container);
40 1
        $this->configureErrorResponseListener($configs, $container);
41 1
    }
42
43
    /**
44
     * Load the service configuration.
45
     *
46
     * @param ContainerBuilder $container
47
     */
48 1
    private function loadServices(ContainerBuilder $container): void
49
    {
50 1
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/..'));
51 1
        $loader->load('Resources/config/services.xml');
52 1
    }
53
54
    /**
55
     * Load the bundle configuration. Returns the normalized config.
56
     *
57
     * @param array            $configs
58
     * @param ContainerBuilder $container
59
     *
60
     * @return array
61
     */
62 1
    private function loadConfiguration(array $configs, ContainerBuilder $container): array
63
    {
64 1
        $configuration = $this->getConfiguration($configs, $container);
65
66 1
        return $this->processConfiguration($configuration, $configs);
67
    }
68
69
    /**
70
     * Set the default content type for given response listener service.
71
     *
72
     * @param string           $serviceId
73
     * @param array            $configs
74
     * @param ContainerBuilder $container
75
     */
76 1
    private function configureResponseListenerDefaultContentType(string $serviceId, array $configs, ContainerBuilder $container): void
77
    {
78 1
        $definition = $container->getDefinition($serviceId);
79 1
        $definition->setArgument(1, $configs['default_content_type']);
80 1
    }
81
82
    /**
83
     * Configure special error response listener arguments. Ex. error expose state.
84
     *
85
     * @param array            $configs
86
     * @param ContainerBuilder $container
87
     */
88 1
    private function configureErrorResponseListener(array $configs, ContainerBuilder $container): void
89
    {
90 1
        $definition = $container->getDefinition(self::SERVICE_EXCEPTION_RESPONSE_LISTENER);
91 1
        $definition->setArgument(2, $configs['expose_all_errors']);
92 1
    }
93
}
94