| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 3 | private function getFileContent(string $file, int $line): string |
|
| 42 | {
|
||
| 43 | 3 | if (! is_file($file)) |
|
| 44 | {
|
||
| 45 | 1 | return ''; |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | $content = file_get_contents($file); |
|
| 49 | 2 | $lines = explode("\n", $content);
|
|
| 50 | 2 | $start = $line - 5; |
|
| 51 | 2 | $length = 10; |
|
| 52 | 2 | if ($start < 0) |
|
| 53 | {
|
||
| 54 | 1 | $start = 0; |
|
| 55 | } |
||
| 56 | |||
| 57 | 2 | $code = array_slice($lines, $start, $length, true); |
|
| 58 | |||
| 59 | 2 | return implode("\n", $code);
|
|
| 60 | } |
||
| 61 | } |