1 | <?php |
||
20 | class Builder |
||
21 | { |
||
22 | /** |
||
23 | * @var InputInterface |
||
24 | */ |
||
25 | protected $input; |
||
26 | |||
27 | /** |
||
28 | * @var Runner |
||
29 | */ |
||
30 | protected $runner; |
||
31 | |||
32 | /** |
||
33 | * @var Serializer |
||
34 | */ |
||
35 | protected $serializer; |
||
36 | |||
37 | /** |
||
38 | * @param array $config |
||
39 | */ |
||
40 | 10 | public function __construct(array $config = []) |
|
54 | |||
55 | /** |
||
56 | * Build and return a regular expression that matches all of the given strings |
||
57 | * |
||
58 | * @param string[] $strings Literal strings to be matched |
||
59 | * @return string Regular expression (without delimiters) |
||
60 | */ |
||
61 | 10 | public function build(array $strings) |
|
75 | |||
76 | /** |
||
77 | * Compare two split strings |
||
78 | * |
||
79 | * Will sort strings in ascending order |
||
80 | * |
||
81 | * @param integer[] $a |
||
82 | * @param integer[] $b |
||
83 | * @return integer |
||
84 | */ |
||
85 | 9 | protected function compareStrings(array $a, array $b) |
|
86 | { |
||
87 | 9 | $i = -1; |
|
88 | 9 | $cnt = min(count($a), count($b)); |
|
89 | 9 | while (++$i < $cnt) |
|
90 | { |
||
91 | 9 | if ($a[$i] !== $b[$i]) |
|
92 | { |
||
93 | 9 | return $a[$i] - $b[$i]; |
|
94 | } |
||
95 | } |
||
96 | |||
97 | 1 | return count($a) - count($b); |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Test whether the list of strings is empty |
||
102 | * |
||
103 | * @param string[] $strings |
||
104 | * @return bool |
||
105 | */ |
||
106 | 10 | protected function isEmpty(array $strings) |
|
110 | |||
111 | /** |
||
112 | * Set the InputInterface instance in $this->input |
||
113 | * |
||
114 | * @param string $inputType |
||
115 | * @param array $inputOptions |
||
116 | * @return void |
||
117 | */ |
||
118 | 10 | protected function setInput($inputType, array $inputOptions) |
|
123 | |||
124 | /** |
||
125 | * Set the Runner instance $in this->runner |
||
126 | * |
||
127 | * @return void |
||
128 | */ |
||
129 | 10 | protected function setRunner() |
|
140 | |||
141 | /** |
||
142 | * Set the Serializer instance in $this->serializer |
||
143 | * |
||
144 | * @param string $outputType |
||
145 | * @param array $outputOptions |
||
146 | * @param string $delimiter |
||
147 | * @return void |
||
148 | */ |
||
149 | 10 | protected function setSerializer($outputType, array $outputOptions, $delimiter) |
|
157 | |||
158 | /** |
||
159 | * Split all given strings by character |
||
160 | * |
||
161 | * @param string[] $strings List of strings |
||
162 | * @return array[] List of arrays |
||
163 | */ |
||
164 | 9 | protected function splitStrings(array $strings) |
|
168 | } |