Skip to content

Commit 2b723e7

Browse files
committed
Revert "Inline and remove Diff::getText()"
This reverts commit a5171c8.
1 parent 519b398 commit 2b723e7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Diff.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function setOptions(array $options): self
148148
*/
149149
public function getA(int $start = 0, ?int $end = null): array
150150
{
151-
return \array_slice($this->a, $start, ($end ?? $start + 1) - $start);
151+
return $this->getText($this->a, $start, $end);
152152
}
153153

154154
/**
@@ -164,7 +164,7 @@ public function getA(int $start = 0, ?int $end = null): array
164164
*/
165165
public function getB(int $start = 0, ?int $end = null): array
166166
{
167-
return \array_slice($this->b, $start, ($end ?? $start + 1) - $start);
167+
return $this->getText($this->b, $start, $end);
168168
}
169169

170170
/**
@@ -220,4 +220,18 @@ public function render(AbstractRenderer $renderer): string
220220
? $renderer::getIdenticalResult()
221221
: $renderer->render();
222222
}
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+
}
223237
}

0 commit comments

Comments
 (0)