Completed
Push — master ( 4f2fad...dd1cd3 )
by Guillaume
07:10
created

ListRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Hogosha\Monitor\Renderer;
4
5
use Hogosha\Monitor\Model\ResultCollection;
6
use Hogosha\Monitor\Renderer\RendererInterface;
7
use Webmozart\Console\Api\IO\IO;
8
9
/**
10
 * @author Guillaume Cavana <[email protected]>
11
 */
12
class ListRenderer implements RendererInterface
13
{
14
    protected $io;
15
16
    /**
17
     * Constructor.
18
     * @param IO $io
19
     */
20
    public function __construct(IO $io)
21
    {
22
        $this->io = $io;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function render(ResultCollection $resultCollection)
29
    {
30
        foreach ($resultCollection as $result) {
31
            $this->io->write("- ");
32
            $this->io->write(sprintf('<fg=white>%s</fg=white>', $result->getName()));
33
            $this->io->write(" = ");
34
            $this->io->write(sprintf('<fg=green>%s</fg=green>', $result->getStatusCode()));
35
            $this->io->write(" = ");
36
            $this->io->write($result->getReponseTime());
37
            $this->io->write("\n");
38
        }
39
    }
40
}
41