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

MergingMetricSource::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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