MultiSource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toTexts() 0 5 3
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