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

Runtime   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 13.33%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 42
ccs 2
cts 15
cp 0.1333
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 3 1
A __construct() 0 3 1
A getDriverClass() 0 19 4
A canCollectCodeCoverage() 0 3 1
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