Skip to content

Commit 312e0ab

Browse files
committed
Add support to non-phpunit code, allow users to add ignore pattern.
I use code-coverage for web applications. add vendors to ignorelist.
1 parent dc421f9 commit 312e0ab

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Filter.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Filter
2222
*/
2323
private $whitelistedFiles = [];
2424

25+
private $ignoreLists = [];
26+
27+
/**
28+
* @param array $ignoreLists
29+
*/
30+
public function setIgnoreLists($ignoreLists) {
31+
$this->ignoreLists = $ignoreLists;
32+
}
2533
/**
2634
* Adds a directory to the whitelist (recursively).
2735
*
@@ -127,8 +135,17 @@ public function isFiltered($filename)
127135
}
128136

129137
$filename = realpath($filename);
130-
138+
if (empty($this->whitelistedFiles)){
139+
foreach($this->ignoreLists as $ignorePattern ){
140+
$pattern = '/'.$ignorePattern.'/';
141+
if (preg_match($pattern, $filename)){
142+
return true;
143+
}
144+
}
145+
return false;
146+
} else{
131147
return !isset($this->whitelistedFiles[$filename]);
148+
}
132149
}
133150

134151
/**

0 commit comments

Comments
 (0)