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

DriverPass::process()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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