Passed
Branch master (9c9e82)
by ANTHONIUS
01:35
created

Runtime::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Doyo\Bridge\CodeCoverage\Environment;
5
6
use Doyo\Bridge\CodeCoverage\Driver\Dummy;
7
use SebastianBergmann\CodeCoverage\Driver\HHVM;
0 ignored issues
show
Bug introduced by
The type SebastianBergmann\CodeCoverage\Driver\HHVM was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
9
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
10
use SebastianBergmann\Environment\Runtime as RuntimeEnvironment;
11
12
/**
13
 * Class Runtime
14
 *
15
 * @method bool isHHVM()
16
 * @method bool isPHPDBG()
17
 * @method bool hasXdebug()
18
 * @method bool hasPHPDBGCodeCoverage()
19
 */
20
final class Runtime implements RuntimeInterface
21
{
22
    private $runtime;
23
24
    public function __construct()
25
    {
26
        $this->runtime = new RuntimeEnvironment();
27
    }
28
29
    public function getDriverClass(): string
30
    {
31
        $driverClass = Dummy::class;
32
33
        // @codeCoverageIgnoreStart
34
        if ($this->isHHVM()) {
35
            $driverClass = HHVM::class;
36
        }
37
38
        if ($this->isPHPDBG()) {
39
            $driverClass = PHPDBG::class;
40
        }
41
42
        if ($this->hasXdebug()){
43
            $driverClass =  Xdebug::class;
44
        }
45
        // @codeCoverageIgnoreEnd
46
47
        return $driverClass;
48
    }
49
50
    /**
51
     * Returns true when Xdebug is supported or
52
     * the runtime used is PHPDBG.
53
     */
54 64
    public function canCollectCodeCoverage(): bool
55
    {
56 64
        return $this->runtime->canCollectCodeCoverage();
57
    }
58
59
    public function __call($name, $arguments)
60
    {
61
        return call_user_func_array([$this->runtime, $name], $arguments);
62
    }
63
}
64