Completed
Push — develop ( c86111...2faf16 )
by ANTHONIUS
21s
created

DriverPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 20
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setupLocalDriver() 0 13 3
A process() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the doyo/behat-coverage-extension project.
5
 *
6
 * (c) Anthonius Munthi <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Doyo\Behat\Coverage\Compiler;
15
16
use SebastianBergmann\Environment\Runtime;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
class DriverPass implements CompilerPassInterface
21
{
22 1
    public function process(ContainerBuilder $container)
23
    {
24 1
        $this->setupLocalDriver($container);
25
    }
26
27 1
    private function setupLocalDriver(ContainerBuilder $container)
28
    {
29 1
        $runtime = new Runtime();
30
31 1
        if (!$runtime->canCollectCodeCoverage()) {
32
            $driver = 'doyo.coverage.driver.dummy';
33 1
        } elseif ($runtime->isPHPDBG()) {
34 1
            $driver = 'doyo.coverage.driver.phpdbg';
35
        } else {
36
            $driver = 'doyo.coverage.driver.xdebug';
37
        }
38
39 1
        $container->setAlias('doyo.coverage.local.driver', $driver);
40
    }
41
}
42