-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPresenter.php
More file actions
54 lines (45 loc) · 1.1 KB
/
Presenter.php
File metadata and controls
54 lines (45 loc) · 1.1 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
<?php
namespace G4\CodeCoverage;
use G4\ValueObject\StringLiteral;
class Presenter
{
/**
* @var Console
*/
private $console;
/**
* @var Metrics
*/
private $metrics;
/**
* Presenter constructor.
* @param Metrics $metrics
* @param Console $console
*/
public function __construct(Metrics $metrics, Console $console)
{
$this->metrics = $metrics;
$this->console = $console;
}
public function stdErr()
{
foreach ($this->makeMetricsFormatter()->format() as $message) {
$this->console->putsErr(new StringLiteral($message));
}
$this->console->exitWithCode(ExitCode::error());
}
public function stdOut()
{
foreach ($this->makeMetricsFormatter()->format() as $message) {
$this->console->putsOut(new StringLiteral($message));
}
$this->console->exitWithCode(ExitCode::success());
}
/**
* @return MetricsFormatter
*/
public function makeMetricsFormatter()
{
return new MetricsFormatter($this->metrics);
}
}