Passed
Pull Request — master (#5)
by Pavel
05:52
created

MergingMetricSource   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 3 1
A __construct() 0 3 1
A getMetrics() 0 4 2
1
<?php
2
3
namespace Lamoda\Metric\Common\Source;
4
5
use Lamoda\Metric\Common\MetricSourceInterface;
6
7
final class MergingMetricSource implements \IteratorAggregate, MetricSourceInterface
8
{
9
    /** @var MetricSourceInterface[] */
10
    private $sources;
11
12 1
    public function __construct(MetricSourceInterface ...$sources)
13
    {
14 1
        $this->sources = $sources;
15 1
    }
16
17
    /** {@inheritdoc} */
18 1
    public function getIterator(): \Traversable
19
    {
20 1
        return $this->getMetrics();
21
    }
22
23
    /** {@inheritdoc} */
24 1
    public function getMetrics(): \Traversable
25
    {
26 1
        foreach ($this->sources as $source) {
27 1
            yield from $source;
28
        }
29 1
    }
30
}
31