Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | final class Series implements WordConverter |
||
12 | { |
||
13 | /** |
||
14 | * @var WordConverter[] Word converters. |
||
15 | */ |
||
16 | private $wordConverters; |
||
17 | |||
18 | /** |
||
19 | * @param WordConverter ...$wordConverters Word converters. |
||
20 | */ |
||
21 | 3 | public function __construct(WordConverter ...$wordConverters) |
|
22 | { |
||
23 | 3 | if ($wordConverters === []) { |
|
24 | 1 | throw new InvalidArgumentException('At least one word converter must be specified.'); |
|
25 | } |
||
26 | |||
27 | 2 | $this->wordConverters = $wordConverters; |
|
28 | 2 | } |
|
29 | |||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | 2 | public function convert(string $word): Traversable |
|
34 | { |
||
35 | 2 | yield from $this->convertWord($word, $this->wordConverters); |
|
36 | 2 | } |
|
37 | |||
38 | 2 | private function convertWord(string $word, array $wordConverters): Traversable |
|
49 | } |
||
50 | 1 | } |
|
51 | } |
||
52 |