RoachPhpExtension::getAlias()   A
last analyzed

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 1
Bugs 0 Features 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 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) 2022 Ne-Lexa <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/roach-php-bundle
12
 */
13
14
namespace Nelexa\RoachPhpBundle\DependencyInjection;
15
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Extension\Extension;
19
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
20
21
/**
22
 * @internal
23
 */
24
final class RoachPhpExtension extends Extension
25
{
26
    public const ALIAS = 'roach_php';
27
28
    public const TAGS = [
29
        \RoachPHP\Spider\SpiderInterface::class => 'roach_php.spider',
30
        \RoachPHP\Support\ConfigurableInterface::class => 'roach_php.configurable',
31
        \RoachPHP\Extensions\ExtensionInterface::class => 'roach_php.extension',
32
    ];
33
34
    public const CLEAR_EVENT_SUBSCRIBER_TAGS = [
35
        self::TAGS[\RoachPHP\Extensions\ExtensionInterface::class],
36
    ];
37
38 1
    public function getAlias(): string
39
    {
40 1
        return self::ALIAS;
41
    }
42
43
    /**
44
     * @throws \Exception
45
     */
46 1
    public function load(array $configs, ContainerBuilder $container): void
47
    {
48 1
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
49 1
        $loader->load('services.php');
50
51 1
        $this->autoconfigureTags($container);
52
    }
53
54 1
    private function autoconfigureTags(ContainerBuilder $container): void
55
    {
56 1
        foreach (self::TAGS as $className => $tag) {
57 1
            $container->registerForAutoconfiguration($className)->addTag($tag);
58
        }
59
    }
60
}
61