Completed
Push — master ( a94ac3...322d21 )
by Richard
05:34
created

CLIReportGenerator::begin_ruleset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 *
5
 * Copyright (c) 2016, 2015 Richard Klees <[email protected]>
6
 *
7
 * This software is licensed under The MIT License. You should have received
8
 * a copy of the licence along with the code.
9
 */
10
11
namespace Lechimp\Dicto\App;
12
13
use Lechimp\Dicto\Analysis\ReportGenerator;
14
use Lechimp\Dicto\Analysis\Violation;
15
use Lechimp\Dicto\Rules\Ruleset;
16
use Lechimp\Dicto\Rules\Rule;
17
18
class CLIReportGenerator implements ReportGenerator {
19
    protected $lines = array();
20
21
    protected function line($content = "") {
22
        $this->lines[] = $content;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function begin_ruleset(Ruleset $rule) {
29
        $this->line("Result of analysis:");
30
        $this->line();
31
    }
32
33
    public function end_ruleset(Ruleset $rule) {
34
        echo implode("\n", $this->lines);
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function begin_rule(Rule $rule) {
41
        $this->line("------------------------------------------------------------------------------");
42
        $this->line($rule->pprint());
43
        $this->line("------------------------------------------------------------------------------");
44
        $this->line();
45
    }
46
47
    public function end_rule(Rule $rule) {
48
        $this->line();
49
        $this->line();
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function report_violation(Violation $violation) {
56
        $this->line($violation->filename()." (".$violation->line_no().")");
57
    }
58
}
59