Total Complexity | 4 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | trait FormatterChaining |
||
11 | { |
||
12 | /** |
||
13 | * @var WordFormatter|null Next word formatter in the chain. |
||
14 | */ |
||
15 | private $next; |
||
16 | |||
17 | /** |
||
18 | * {@inheritDoc} |
||
19 | */ |
||
20 | 2 | public function setNext(?WordFormatter $next): void |
|
21 | { |
||
22 | 2 | $this->next = $next; |
|
23 | 2 | } |
|
24 | |||
25 | /** |
||
26 | * {@inheritDoc} |
||
27 | */ |
||
28 | 2 | public function getNext(): ?WordFormatter |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param iterable<string> $words Words to format. |
||
35 | * @return Traversable<string> The words formatted by the word formatter chain. May contain duplicates. |
||
36 | */ |
||
37 | 46 | public function apply(iterable $words): Traversable |
|
43 | } |
||
44 | 46 | } |
|
45 | |||
46 | /** |
||
47 | * @param iterable<string> $words Words to format. |
||
48 | * @return Traversable<string> The words formatted by this word formatter. May contain duplicates. |
||
49 | */ |
||
50 | abstract protected function applyCurrent(iterable $words): Traversable; |
||
51 | } |
||
52 |