@@ -148,7 +148,7 @@ public function setOptions(array $options): self
148
148
*/
149
149
public function getA (int $ start = 0 , ?int $ end = null ): array
150
150
{
151
- return \array_slice ($ this ->a , $ start , ( $ end ?? $ start + 1 ) - $ start );
151
+ return $ this -> getText ($ this ->a , $ start , $ end );
152
152
}
153
153
154
154
/**
@@ -164,7 +164,7 @@ public function getA(int $start = 0, ?int $end = null): array
164
164
*/
165
165
public function getB (int $ start = 0 , ?int $ end = null ): array
166
166
{
167
- return \array_slice ($ this ->b , $ start , ( $ end ?? $ start + 1 ) - $ start );
167
+ return $ this -> getText ($ this ->b , $ start , $ end );
168
168
}
169
169
170
170
/**
@@ -220,4 +220,18 @@ public function render(AbstractRenderer $renderer): string
220
220
? $ renderer ::getIdenticalResult ()
221
221
: $ renderer ->render ();
222
222
}
223
+
224
+ /**
225
+ * The work horse of getA() and getB().
226
+ *
227
+ * @param string[] $lines the array of lines
228
+ * @param int $start the starting number
229
+ * @param null|int $end the ending number. If not supplied, only the item in $start will be sliced.
230
+ *
231
+ * @return string[] array of all of the lines between the specified range
232
+ */
233
+ private function getText (array $ lines , int $ start = 0 , ?int $ end = null ): array
234
+ {
235
+ return \array_slice ($ lines , $ start , ($ end ?? $ start + 1 ) - $ start );
236
+ }
223
237
}
0 commit comments