Completed
Push — master ( 88991f...6ec29e )
by Jakub
01:26
created

PcovEngine::isAvailable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace MyTester\CodeCoverage;
5
6
/**
7
 * Pcov engine for code coverage collector
8
 *
9
 * @author Jakub Konečný
10
 * @internal
11
 */
12
final class PcovEngine implements \MyTester\ICodeCoverageEngine {
13
  public function getName(): string {
14
    return "pcov";
15
  }
16
17
  public function isAvailable(): bool {
18
    return extension_loaded("pcov");
19
  }
20
21
  public function start(): void {
22
    \pcov\start();
0 ignored issues
show
Bug introduced by
The function start was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
    /** @scrutinizer ignore-call */ 
23
    \pcov\start();
Loading history...
23
  }
24
25
  public function collect(): array {
26
    $positive = $negative = [];
27
28
    \pcov\stop();
0 ignored issues
show
Bug introduced by
The function stop was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
    /** @scrutinizer ignore-call */ 
29
    \pcov\stop();
Loading history...
29
30
    foreach(\pcov\collect() as $file => $lines) {
0 ignored issues
show
Bug introduced by
The function collect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
    foreach(/** @scrutinizer ignore-call */ \pcov\collect() as $file => $lines) {
Loading history...
31
      if(!file_exists($file)) {
32
        continue;
33
      }
34
35
      foreach($lines as $number => $value) {
36
        if($value > 0) {
37
          $positive[$file][$number] = $value;
38
        } else {
39
          $negative[$file][$number] = $value;
40
        }
41
      }
42
    }
43
44
    return [$positive, $negative,];
45
  }
46
}
47
?>