File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace SebastianBergmann \PHPCOV ;
3
+
4
+ use SebastianBergmann \CodeCoverage \Driver \Driver ;
5
+ use SebastianBergmann \CodeCoverage \RawCodeCoverageData ;
6
+
7
+ final class XdebugFileDriver extends Driver
8
+ {
9
+ public function __construct ($ fileName , $ mapFrom = "" , $ mapTo = "" )
10
+ {
11
+ $ this ->data = array ();
12
+
13
+ foreach (json_decode (file_get_contents ($ fileName ), true ) as $ key => $ value ) {
14
+ $ this ->data [str_replace ($ mapFrom , $ mapTo , $ key )] = $ value ;
15
+ }
16
+ }
17
+
18
+ public function canCollectBranchAndPathCoverage (): bool
19
+ {
20
+ return true ;
21
+ }
22
+
23
+ public function canDetectDeadCode (): bool
24
+ {
25
+ return true ;
26
+ }
27
+
28
+ public function start (): void
29
+ {
30
+ }
31
+
32
+ public function stop (): RawCodeCoverageData
33
+ {
34
+ if ($ this ->collectsBranchAndPathCoverage ()) {
35
+ return RawCodeCoverageData::fromXdebugWithPathCoverage ($ this ->data );
36
+ }
37
+
38
+ return RawCodeCoverageData::fromXdebugWithoutPathCoverage ($ this ->data );
39
+ }
40
+
41
+ public function nameAndVersion (): string
42
+ {
43
+ return 'Xdebug file driver ' ;
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments