Completed
Push — master ( 86b2cd...b16d12 )
by Richard
03:26
created

CombinedListener   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 16
lcom 1
cbo 1

9 Methods

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