Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
20 | public function getPlaceInFile(int $linesBefore = 4, int $linesAfter = 4): array |
||
21 | { |
||
22 | $context = []; |
||
23 | |||
24 | $offset = $this->line - $linesBefore - 1; |
||
25 | |||
26 | if ($offset < 0) { |
||
27 | $linesBefore = 0; |
||
28 | $offset = 0; |
||
29 | } |
||
30 | |||
31 | $file = new SplFileObject($this->file, 'rb'); |
||
32 | $iterator = new LimitIterator($file, $offset, $linesBefore + $linesAfter + 1); |
||
33 | $index = $offset + 1; |
||
34 | |||
35 | foreach ($iterator as $text) { |
||
36 | $context[$index] = $text; |
||
37 | $index++; |
||
38 | } |
||
39 | |||
40 | return $context; |
||
41 | } |
||
43 |