GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f7c46f...5a08eb )
by Freek
03:22 queued 01:51
created

FileParser::getParsed()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 29
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 3
nop 0
dl 0
loc 29
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\CodeOutline;
4
5
class FileParser implements Parser
6
{
7
    /** @var string */
8
    protected $path;
9
10
    public function __construct(string $path)
11
    {
12
        $this->path = $path;
13
    }
14
15
    public function getParsed(): array
16
    {
17
        $contents = file_get_contents($this->path);
18
19
        $lines = explode(PHP_EOL, $contents);
20
21
        $outline = [];
22
23
        foreach ($lines as $line) {
24
            if (!strlen($line)) {
25
                $outline[] = null;
26
27
                continue;
28
            }
29
30
            $totalLineCount = strlen($line);
31
32
            $characterLineCount = strlen(ltrim($line));
33
34
            $indentLineCount = $totalLineCount - $characterLineCount;
35
36
            $indentLine = array_fill(0, $indentLineCount, -1);
37
38
            $characterLine = array_fill(0, $characterLineCount, 1);
39
40
            $outline[] = array_merge($indentLine, $characterLine);
41
        }
42
43
        return $outline;
44
    }
45
}
46