MultiSource::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
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
    public function toTexts(array $context = []): iterable
26
    {
27
        foreach ($this->sources as $source) {
28
            foreach ($source->toTexts($context) as $text) {
29
                yield $text->mergeContext($context, true);
30
            }
31
        }
32
    }
33
}
34