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 (#1)
by Pascal
02:17
created

ApiBundleExtension::getAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 ApiBundleExtension extends Extension
13
{
14
    private const SERVICE_EXCEPTION_RESOURCE_LISTENER = 'saikootau_api.event.listener.exception_response';
15
    private const SERVICE_RESOURCE_RESPONSE_LISTENER = 'saikootau_api.event.listener.resource_response';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    public function getAlias(): string
21
    {
22 1
        return 'saikootau_api';
23
    }
24
25
    /**
26
     * @param array            $config
27
     * @param ContainerBuilder $container
28
     *
29
     * @return Configuration
30
     */
31 1
    public function getConfiguration(array $config, ContainerBuilder $container): Configuration
32
    {
33 1
        return new Configuration();
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function load(array $configs, ContainerBuilder $container): void
40
    {
41 1
        $this->loadServices($container);
42
43 1
        $configs = $this->loadConfiguration($configs, $container);
44 1
        $this->configureResponseListenerDefaultContentType(self::SERVICE_EXCEPTION_RESOURCE_LISTENER, $configs, $container);
45 1
        $this->configureResponseListenerDefaultContentType(self::SERVICE_EXCEPTION_RESOURCE_LISTENER, $configs, $container);
46 1
        $this->configureErrorResponseListener($configs, $container);
47 1
    }
48
49
    /**
50
     * Load the service configuration.
51
     *
52
     * @param ContainerBuilder $container
53
     */
54 1
    private function loadServices(ContainerBuilder $container): void
55
    {
56 1
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/..'));
57 1
        $loader->load('Resources/config/services.xml');
58 1
    }
59
60
    /**
61
     * Load the bundle configuration. Returns the normalized config.
62
     *
63
     * @param array            $configs
64
     * @param ContainerBuilder $container
65
     *
66
     * @return array
67
     */
68 1
    private function loadConfiguration(array $configs, ContainerBuilder $container): array
69
    {
70 1
        $configuration = $this->getConfiguration($configs, $container);
71
72 1
        return $this->processConfiguration($configuration, $configs);
73
    }
74
75
    /**
76
     * Set the default content type for given response listener service.
77
     *
78
     * @param string           $serviceId
79
     * @param array            $configs
80
     * @param ContainerBuilder $container
81
     */
82 1
    private function configureResponseListenerDefaultContentType(string $serviceId, array $configs, ContainerBuilder $container): void
83
    {
84 1
        $definition = $container->getDefinition($serviceId);
85 1
        $definition->setArgument(1, $configs['default_content_type']);
86 1
    }
87
88
    /**
89
     * Configure special error response listener arguments. Ex. error expose state.
90
     *
91
     * @param array            $configs
92
     * @param ContainerBuilder $container
93
     */
94 1
    private function configureErrorResponseListener(array $configs, ContainerBuilder $container): void
95
    {
96 1
        $definition = $container->getDefinition(self::SERVICE_EXCEPTION_RESOURCE_LISTENER);
97 1
        $definition->setArgument(2, $configs['expose_all_errors']);
98 1
    }
99
}
100