-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathProxy.php
More file actions
71 lines (61 loc) · 1.42 KB
/
Proxy.php
File metadata and controls
71 lines (61 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Proxy Code Coverage Driver
*
* @copyright 2013 Anthon Pang
*
* @license BSD-2-Clause
*/
namespace LeanPHP\Behat\CodeCoverage\Driver;
use Symfony\Component\DependencyInjection\ContainerInterface;
use LeanPHP\Behat\CodeCoverage\Common\Model\Aggregate;
use SebastianBergmann\CodeCoverage\Driver\Driver as DriverInterface;
/**
* Proxy driver
*
* @author Anthon Pang <apang@softwaredevelopment.ca>
*/
class Proxy implements DriverInterface
{
/**
* @var array
*/
private $drivers = array();
/**
* Register driver
*
* @param DriverInterface|null $driver
*/
public function addDriver(DriverInterface $driver = null)
{
if ($driver) {
$this->drivers[] = $driver;
}
}
/**
* {@inheritdoc}
*/
public function start(bool $determineUnusedAndDead = true): void
{
foreach ($this->drivers as $driver) {
$driver->start($determineUnusedAndDead);
}
}
/**
* {@inheritdoc}
*/
public function stop(): array
{
$aggregate = new Aggregate();
foreach ($this->drivers as $driver) {
$coverage = $driver->stop();
if (! $coverage) {
continue;
}
foreach ($coverage as $class => $counts) {
$aggregate->update($class, $counts);
}
}
return $aggregate->getCoverage();
}
}