-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSymfonyConsoleRenderer.php
79 lines (70 loc) · 2.08 KB
/
SymfonyConsoleRenderer.php
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
72
73
74
75
76
77
78
79
<?php
/**
* This file is part of the phpkata project.
*
* (c) Yannick Voyer (http://github.com/yvoyer)
*/
namespace Star\Kata\Infrastructure\Symfony\View\Cli;
use Star\Kata\Domain\DTO\StartedKata;
use Star\Kata\Domain\Exception\KataException;
use Star\Kata\Domain\Objective\Objective;
use Star\Kata\Domain\Objective\ObjectiveResult;
use Star\Kata\Domain\View\ResultRenderer;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class SymfonyConsoleRenderer
*
* @author Yannick Voyer (http://github.com/yvoyer)
*
* @package Star\Kata\Domain\View\Cli
*/
final class SymfonyConsoleRenderer implements ResultRenderer
{
/**
* @var OutputInterface
*/
private $output;
/**
* @param OutputInterface $output
*/
public function __construct(OutputInterface $output)
{
$this->output = $output;
}
/**
* @param ObjectiveResult $result
*/
public function displaySuccess(ObjectiveResult $result)
{
$this->output->writeln('<comment>You finished all the objectives, ' . $result->points() . ' points awarded.</comment>');
}
/**
* @param ObjectiveResult $result
*/
public function displayFailure(ObjectiveResult $result)
{
$this->output->writeln('<error>You succeed ' . $result->points() . '/' . $result->maxPoints() . ' objectives, ' . $result->points() . ' points awarded. Keep trying.</error>');
}
/**
* @param Objective $objective
*/
public function displayObjective(Objective $objective)
{
$this->output->writeln('Objective: <info>' . $objective->description() . '</info>');
}
/**
* @param KataException $exception
*/
public function displayError(KataException $exception)
{
$this->output->writeln('<error>' . $exception->getMessage() . '</error>');
}
/**
* @param StartedKata $kata
*/
public function displayKata(StartedKata $kata)
{
$this->output->writeln("Kata: <comment>{$kata->getName()}</comment>");
$this->output->writeln("Description: <info>{$kata->getDescription()}</info>");
}
}