Runtime   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 54
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 14

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hasPCOV() 0 3 3
A __call() 0 3 1
A __construct() 0 3 1
A canCollectCodeCoverage() 0 3 3
A getDriverClass() 0 26 6
1
<?php
2
3
/*
4
 * This file is part of the doyo/code-coverage project.
5
 *
6
 * (c) Anthonius Munthi <https://itstoni.com>
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\Bridge\CodeCoverage\Environment;
15
16
use Doyo\Bridge\CodeCoverage\Driver\Dummy;
17
use Doyo\Bridge\CodeCoverage\Driver\PCOV;
18
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...
19
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
20
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
21
use SebastianBergmann\Environment\Runtime as RuntimeEnvironment;
22
23
/**
24
 * Class Runtime.
25
 *
26
 * @method bool isHHVM()
27
 * @method bool isPHPDBG()
28
 * @method bool hasXdebug()
29
 * @method bool hasPHPDBGCodeCoverage()
30
 * @method bool isPHP()
31
 */
32
final class Runtime implements RuntimeInterface
33
{
34
    private $runtime;
35
36 35
    public function __construct()
37
    {
38 35
        $this->runtime = new RuntimeEnvironment();
39
    }
40
41 35
    public function getDriverClass(): string
42
    {
43 35
        $driverClass = Dummy::class;
44
45
        // @codeCoverageIgnoreStart
46
        if ($this->isHHVM()) {
47
            $driverClass = HHVM::class;
48
        }
49
50
        if ($this->isPHPDBG()) {
51
            $driverClass = PHPDBG::class;
52
        }
53
54
        if (
55
            version_compare(PHP_VERSION, '7.0', '>')
56
            && $this->hasPCOV()
57
        ) {
58
            //$driverClass = PCOV::class;
59
        }
60
61
        if ($this->hasXdebug()) {
62
            $driverClass =  Xdebug::class;
63
        }
64
        // @codeCoverageIgnoreEnd
65
66 35
        return $driverClass;
67
    }
68
69 116
    public function hasPCOV()
70
    {
71 116
        return $this->isPHP() && \extension_loaded('pcov') && ini_get('pcov.enabled');
72
    }
73
74
    /**
75
     * Returns true when Xdebug is supported or
76
     * the runtime used is PHPDBG.
77
     */
78 116
    public function canCollectCodeCoverage(): bool
79
    {
80 116
        return $this->hasXdebug() || $this->hasPCOV() || $this->hasPHPDBGCodeCoverage();
81
    }
82
83 116
    public function __call($name, $arguments)
84
    {
85 116
        return \call_user_func_array([$this->runtime, $name], $arguments);
86
    }
87
}
88