1 | <?php |
||
26 | final class StaggeredDelimiterProcessor implements DelimiterProcessorInterface |
||
27 | { |
||
28 | private $delimiterChar; |
||
29 | |||
30 | private $minLength = 0; |
||
31 | |||
32 | /** @var array<int, DelimiterProcessorInterface>|DelimiterProcessorInterface[] */ |
||
33 | private $processors = []; // keyed by minLength in reverse order |
||
34 | |||
35 | 6 | public function __construct(string $char, DelimiterProcessorInterface $processor) |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 3 | public function getOpeningCharacter(): string |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 3 | public function getClosingCharacter(): string |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 3 | public function getMinLength(): int |
|
64 | |||
65 | /** |
||
66 | * Adds the given processor to this staggered delimiter processor |
||
67 | * |
||
68 | * @param DelimiterProcessorInterface $processor |
||
69 | */ |
||
70 | 6 | public function add(DelimiterProcessorInterface $processor) |
|
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | 3 | public function getDelimiterUse(Delimiter $opener, Delimiter $closer): int |
|
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | 3 | public function process(Text $opener, Text $closer, int $delimiterUse) |
|
99 | |||
100 | 3 | private function findProcessor(int $len): DelimiterProcessorInterface |
|
115 | } |
||
116 |