Completed
Pull Request — master (#61)
by Samuel
02:27
created

NamespacedCollector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A collect() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the Tolerance package.
5
 *
6
 * (c) Samuel ROZE <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tolerance\Metrics\Collector;
13
14
use Tolerance\Metrics\Metric;
15
16
final class NamespacedCollector implements MetricCollector
17
{
18
    /**
19
     * @var MetricCollector
20
     */
21
    private $decoratedCollector;
22
23
    /**
24
     * @var string
25
     */
26
    private $namespace;
27
28
    /**
29
     * @param MetricCollector $decoratedCollector
30
     * @param string          $namespace
31
     */
32
    public function __construct(MetricCollector $decoratedCollector, $namespace)
33
    {
34
        $this->decoratedCollector = $decoratedCollector;
35
        $this->namespace = $namespace;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function collect()
42
    {
43
        return array_map(function (Metric $metric) {
44
            return new Metric($this->namespace.'.'.$metric->getName(), $metric->getValue());
45
        }, $this->decoratedCollector->collect());
46
    }
47
}
48