Completed
Push — master ( 5d5235...483143 )
by Guillaume
04:19
created

ListRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
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 Webmozart\Console\Api\IO\IO;
7
8
/**
9
 * @author Guillaume Cavana <[email protected]>
10
 */
11
class ListRenderer implements RendererInterface
12
{
13
    protected $io;
14
15
    /**
16
     * Constructor.
17
     *
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
        $format = "[%s][%s] %s - %s";
31
32
        foreach ($resultCollection as $result) {
33
            $this->io->write(
34
                sprintf(
35
                    $format,
36
                    $result->getExpectedStatus() != $result->getStatusCode() ? 'FAIL' : 'OK',
37
                    $result->getStatusCode(),
38
                    $result->getName(),
39
                    $result->getReponseTime()
40
                )."\n"
41
            );
42
        }
43
    }
44
}
45