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

ListRenderer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 16 3
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