Passed
Push — master ( a93e2d...567501 )
by Philippe
03:03
created

MultiSource::toTexts()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSpellcheck\Source;
6
7
use Webmozart\Assert\Assert;
8
9
class MultiSource implements SourceInterface
10
{
11
    /**
12
     * @var iterable<SourceInterface>
13
     */
14
    private $sources;
15
16
    /**
17
     * @param iterable<SourceInterface> $sources
18
     */
19
    public function __construct(iterable $sources)
20
    {
21
        Assert::allIsInstanceOf($sources, SourceInterface::class);
22
        $this->sources = $sources;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function toTexts(array $context = []): iterable
29
    {
30
        foreach ($this->sources as $source) {
31
            foreach ($source->toTexts($context) as $text) {
32
                yield $text->mergeContext($context, true);
33
            }
34
        }
35
    }
36
}
37