CollectorCollection::callAll()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Flagbit\Bundle\MetricsBundle\Collector;
4
5
use Beberlei\Metrics\Collector\Collector;
6
7
class CollectorCollection implements CollectorInterface
8
{
9
    /**
10
     * @var Collector[]
11
     */
12
    private $collectors;
13
14
    /**
15
     * @param Collector $collector
16
     */
17 5
    public function addCollector(Collector $collector)
18
    {
19 5
        $this->collectors[] = $collector;
20 5
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 1
    public function increment($variable)
26
    {
27 1
        $this->callAll('increment', [$variable]);
28 1
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function decrement($variable)
34
    {
35 1
        $this->callAll('decrement', [$variable]);
36 1
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function timing($variable, $time)
42
    {
43 1
        $this->callAll('timing', [$variable, $time]);
44 1
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function measure($variable, $value)
50
    {
51 1
        $this->callAll('measure', [$variable, $value]);
52 1
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 4
    private function callAll($method, array $arguments)
58
    {
59 4
        foreach ($this->collectors as $collector) {
60 4
            $collector->{$method}(...$arguments);
61
        }
62 4
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67 1
    public function flush()
68
    {
69 1
        foreach ($this->collectors as $collector) {
70 1
            $collector->flush();
71
        }
72 1
    }
73
}
74