Skip to content

Commit 88a9995

Browse files
Make PHP_CodeCoverage_Filter injectable.
1 parent cb54b3e commit 88a9995

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

PHP/CodeCoverage.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ class PHP_CodeCoverage
6262
const STORAGE_ARRAY = 0;
6363
const STORAGE_SPLOBJECTSTORAGE = 1;
6464

65+
protected $filter;
6566
protected $storageType;
6667

6768
protected $currentId;
6869
protected $data;
6970

70-
public $filter;
71-
7271
/**
7372
* List of covered files.
7473
*
@@ -79,13 +78,19 @@ class PHP_CodeCoverage
7978
/**
8079
* Constructor.
8180
*
82-
* @param integer $storageType
81+
* @param PHP_CodeCoverage_Filter $filter
82+
* @param integer $storageType
8383
*/
84-
public function __construct($storageType = self::STORAGE_SPLOBJECTSTORAGE)
84+
public function __construct(PHP_CodeCoverage_Filter $filter = NULL, $storageType = self::STORAGE_SPLOBJECTSTORAGE)
8585
{
86+
if ($filter === NULL) {
87+
$filter = new PHP_CodeCoverage_Filter;
88+
}
89+
90+
$this->filter = $filter;
8691
$this->storageType = $storageType;
92+
8793
$this->clear();
88-
$this->filter = new PHP_CodeCoverage_Filter;
8994
}
9095

9196
/**
@@ -247,6 +252,16 @@ public function getDeadLines(array $data)
247252
return $this->getLinesByStatus($data, -2);
248253
}
249254

255+
/**
256+
* Returns the PHP_CodeCoverage_Filter used.
257+
*
258+
* @return PHP_CodeCoverage_Filter
259+
*/
260+
public function filter()
261+
{
262+
return $this->filter;
263+
}
264+
250265
/**
251266
* Filters lines by status.
252267
*

0 commit comments

Comments
 (0)