Completed
Push — master ( 1e9ef5...3740bc )
by Richard
05:53 queued 29s
created

CLIReportGenerator   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 53
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A line() 0 3 1
A begin_run() 0 2 1
A end_run() 0 2 1
A begin_ruleset() 0 4 1
A end_ruleset() 0 3 1
A begin_rule() 0 6 1
A end_rule() 0 4 1
A report_violation() 0 3 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 license 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_run($commit_hash) {
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function end_run() {
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function begin_ruleset(Ruleset $rule) {
41
        $this->line("Result of analysis:");
42
        $this->line();
43
    }
44
45
    public function end_ruleset() {
46
        echo implode("\n", $this->lines);
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function begin_rule(Rule $rule) {
53
        $this->line("------------------------------------------------------------------------------");
54
        $this->line($rule->pprint());
55
        $this->line("------------------------------------------------------------------------------");
56
        $this->line();
57
    }
58
59
    public function end_rule() {
60
        $this->line();
61
        $this->line();
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function report_violation(Violation $violation) {
68
        $this->line($violation->filename()." (".$violation->line_no().")");
69
    }
70
}
71