Passed
Push — master ( 4af0b3...75a0ae )
by Dawid
02:55
created

Utils   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 29
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addOrReplaceDefinitionArgument() 0 8 2
A clearListenerTags() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\DependencyInjection;
6
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
9
10
class Utils
11
{
12
    /**
13
     * @param Definition $definition
14
     * @param int        $index
15
     * @param mixed      $value
16
     *
17
     * @throws OutOfBoundsException
18
     */
19 12
    public static function addOrReplaceDefinitionArgument(Definition $definition, int $index, $value): void
20
    {
21 12
        if (array_key_exists($index, $definition->getArguments())) {
22
            $definition->replaceArgument($index, $value);
23
        } else {
24 12
            $definition->setArgument($index, $value);
25
        }
26 12
    }
27
28
    /**
29
     * @param Definition $definition
30
     */
31 9
    public static function clearListenerTags(Definition $definition): void
32
    {
33 9
        $definition->clearTag('kernel.event_subscriber');
34 9
        $definition->clearTag('kernel.event_listener');
35
36 9
        $definition->setPublic(false);
37 9
    }
38
}
39