Completed
Branch master (1f9106)
by Nils
03:23
created

CliReporter::setOutputInterface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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\Scanner\Result;
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(Result $result)
32
    {
33
        $this->output->writeln('   <error> ' . $result->getUrl() . ' </error> coming from ' . (string) $this->retriever->getComingFrom($result->getUrl()));
34
        foreach ($result->getMessages() as $ruleName => $message) {
35
            $this->output->writeln('    - ' . $message . " [rule: $ruleName]");
36
        }
37
        $this->output->writeln('');
38
    }
39
40
    protected function renderSuccess(Result $result)
41
    {
42
        $this->output->writeln('   <info> ' . $result->getUrl() . ' </info> all tests passed');
43
    }
44
}
45