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

CliReporter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 8
Bugs 2 Features 1
Metric Value
wmc 5
c 8
b 2
f 1
lcom 1
cbo 3
dl 0
loc 36
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setResponseRetriever() 0 4 1
A setOutputInterface() 0 4 1
A renderSuccess() 0 4 1
A renderFailure() 0 8 2
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