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

MergingMetricSource::getMetrics()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
crap 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