Passed
Push — feature/v4 ( 2fc063...abe85a )
by Samuel
05:52
created

PublicForTestsCompilerPass   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 8
c 1
b 1
f 0
dl 0
loc 21
ccs 9
cts 10
cp 0.9
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 4
A isPHPUnit() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ivory\GoogleMapBundle\DependencyInjection\Compiler;
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
class PublicForTestsCompilerPass implements CompilerPassInterface
11
{
12 56
    public function process(ContainerBuilder $container): void
13
    {
14 56
        if (!$this->isPHPUnit()) {
15
            return;
16
        }
17
18 56
        foreach ($container->getDefinitions() as $definition) {
19 56
            $definition->setPublic(true);
20
        }
21
22 56
        foreach ($container->getAliases() as $definition) {
23 56
            $definition->setPublic(true);
24
        }
25 56
    }
26
27 56
    private function isPHPUnit(): bool
28
    {
29
        // there constants are defined by PHPUnit
30 56
        return defined('PHPUNIT_COMPOSER_INSTALL') || defined('__PHPUNIT_PHAR__');
31
    }
32
}
33