Completed
Branch code-coverage (571de7)
by Jakub
02:21
created

PcovEngine   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 33
rs 10
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isAvailable() 0 2 1
A getName() 0 2 1
A collect() 0 20 5
A start() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace MyTester\CodeCoverage;
5
6
final class PcovEngine implements \MyTester\ICodeCoverageEngine {
7
  public function getName(): string {
8
    return "pcov";
9
  }
10
11
  public function isAvailable(): bool {
12
    return extension_loaded("pcov");
13
  }
14
15
  public function start(): void {
16
    \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

16
    /** @scrutinizer ignore-call */ 
17
    \pcov\start();
Loading history...
17
  }
18
19
  public function collect(): array {
20
    $positive = $negative = [];
21
22
    \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

22
    /** @scrutinizer ignore-call */ 
23
    \pcov\stop();
Loading history...
23
24
    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

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