DefaultTaggingMetricSource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getMetrics() 0 4 2
A getIterator() 0 3 1
1
<?php
2
3
namespace Lamoda\Metric\Common\Source;
4
5
use Lamoda\Metric\Common\DefaultTagsMetric;
6
use Lamoda\Metric\Common\MetricSourceInterface;
7
8
final class DefaultTaggingMetricSource implements \IteratorAggregate, MetricSourceInterface
9
{
10
    /** @var MetricSourceInterface */
11
    private $source;
12
    /** @var string[] */
13
    private $tags;
14
15
    /**
16
     * ExtraTagsMetricSource constructor.
17
     *
18
     * @param MetricSourceInterface $source
19
     * @param string[]              $tags
20
     */
21 3
    public function __construct(MetricSourceInterface $source, array $tags = [])
22
    {
23 3
        $this->source = $source;
24 3
        $this->tags = $tags;
25 3
    }
26
27
    /** {@inheritdoc} */
28 3
    public function getIterator(): \Traversable
29
    {
30 3
        return $this->getMetrics();
31
    }
32
33
    /** {@inheritdoc} */
34 3
    public function getMetrics(): \Traversable
35
    {
36 3
        foreach ($this->source as $metric) {
37 3
            yield new DefaultTagsMetric($metric, $this->tags);
38
        }
39 3
    }
40
}
41