Completed
Push — master ( 8ec94e...9abf36 )
by Nils
02:18
created

CliReporter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setResponseRetriever() 0 4 1
A setOutputInterface() 0 4 1
A renderFailure() 0 6 1
A renderSuccess() 0 4 1
A renderSkipped() 0 5 1
1
<?php
2
3
namespace whm\Smoke\Extensions\SmokeReporter\Reporter;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use whm\Smoke\Extensions\SmokeResponseRetriever\Retriever\Retriever;
7
use whm\Smoke\Rules\CheckResult;
8
9
abstract class CliReporter implements Reporter
10
{
11
    /**
12
     * @var OutputInterface
13
     */
14
    protected $output;
15
16
    /**
17
     * @var Retriever
18
     */
19
    protected $retriever;
20
21
    public function setResponseRetriever(Retriever $retriever)
22
    {
23
        $this->retriever = $retriever;
24
    }
25
26
    protected function setOutputInterface(OutputInterface $output)
27
    {
28
        $this->output = $output;
29
    }
30
31
    protected function renderFailure(CheckResult $result)
32
    {
33
        $this->output->writeln('   <error> ' . (string) $result->getResponse()->getUri() . ' </error> coming from ' . (string) $this->retriever->getComingFrom($result->getResponse()->getUri()));
34
        $this->output->writeln('    - ' . $result->getMessage() . ' [rule: ' . $result->getRuleName() . ']');
35
        $this->output->writeln('');
36
    }
37
38
    protected function renderSuccess(CheckResult $result)
39
    {
40
        $this->output->writeln('   <info> ' . (string) $result->getResponse()->getUri() . ' </info> all tests passed');
41
    }
42
43
    protected function renderSkipped(CheckResult $result)
44
    {
45
        $this->output->writeln('   <comment> ' . (string) $result->getResponse()->getUri() . ' </comment>test skipped');
46
        $this->output->writeln('    - ' . $result->getMessage() . ' [rule: ' . $result->getRuleName() . ']');
47
    }
48
}
49