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\Analysis; |
12
|
|
|
|
13
|
|
|
use Lechimp\Dicto\Rules\Ruleset; |
14
|
|
|
use Lechimp\Dicto\Rules\Rule; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Combines multiple report generators into one. |
18
|
|
|
*/ |
19
|
|
|
class CombinedReportGenerators implements ReportGenerator { |
20
|
|
|
/** |
21
|
|
|
* @var ReportGenerator[] |
22
|
|
|
*/ |
23
|
|
|
protected $generators; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param ReportGenerator[] |
27
|
|
|
*/ |
28
|
|
|
public function __construct(array $generators) { |
29
|
8 |
|
$this->generators = array_map(function(ReportGenerator $g) { |
30
|
8 |
|
return $g; |
31
|
8 |
|
}, $generators); |
32
|
8 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return ReportGenerator[] |
36
|
|
|
*/ |
37
|
1 |
|
public function generators() { |
38
|
1 |
|
return $this->generators; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @inheritdocs |
43
|
|
|
*/ |
44
|
1 |
|
public function begin_run($commit_hash) { |
45
|
1 |
|
foreach ($this->generators as $g) { |
46
|
1 |
|
$g->begin_run($commit_hash); |
47
|
1 |
|
} |
48
|
1 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritdocs |
52
|
|
|
*/ |
53
|
1 |
|
public function end_run() { |
54
|
1 |
|
foreach ($this->generators as $g) { |
55
|
1 |
|
$g->end_run(); |
56
|
1 |
|
} |
57
|
1 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritdocs |
61
|
|
|
*/ |
62
|
1 |
|
public function begin_ruleset(Ruleset $ruleset) { |
63
|
1 |
|
foreach ($this->generators as $g) { |
64
|
1 |
|
$g->begin_ruleset($ruleset); |
65
|
1 |
|
} |
66
|
1 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritdocs |
70
|
|
|
*/ |
71
|
1 |
|
public function end_ruleset() { |
72
|
1 |
|
foreach ($this->generators as $g) { |
73
|
1 |
|
$g->end_ruleset(); |
74
|
1 |
|
} |
75
|
1 |
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @inheritdocs |
79
|
|
|
*/ |
80
|
1 |
|
public function begin_rule(Rule $rule) { |
81
|
1 |
|
foreach ($this->generators as $g) { |
82
|
1 |
|
$g->begin_rule($rule); |
83
|
1 |
|
} |
84
|
1 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @inheritdocs |
88
|
|
|
*/ |
89
|
1 |
|
public function end_rule() { |
90
|
1 |
|
foreach ($this->generators as $g) { |
91
|
1 |
|
$g->end_rule(); |
92
|
1 |
|
} |
93
|
1 |
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @inheritdocs |
97
|
|
|
*/ |
98
|
1 |
|
public function report_violation(Violation $violation) { |
99
|
1 |
|
foreach ($this->generators as $g) { |
100
|
1 |
|
$g->report_violation($violation); |
101
|
1 |
|
} |
102
|
1 |
|
} |
103
|
|
|
} |
104
|
|
|
|