Completed
Pull Request — master (#84)
by
unknown
06:22
created

AbstractOverrideBoolParameterAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 23
ccs 0
cts 5
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ekino Drupal Debug project.
7
 *
8
 * (c) ekino
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\Drupal\Debug\Action;
15
16
use Ekino\Drupal\Debug\Exception\NotSupportedException;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19
abstract class AbstractOverrideBoolParameterAction implements CompilerPassActionInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function process(ContainerBuilder $container): void
25
    {
26
        if (!$container->hasParameter(static::getParameterId())) {
27
            throw new NotSupportedException(\sprintf('The "%s" parameter should already be set in the container builder.', static::getParameterId()));
28
        }
29
30
        $container->setParameter(static::getParameterId(), $this->getOverride());
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    abstract protected static function getParameterId(): string;
37
38
    /**
39
     * @return bool
40
     */
41
    abstract protected function getOverride(): bool;
42
}
43