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.

Line   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 14
c 1
b 1
f 0
dl 0
loc 41
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 9 1
A getMaximumCharacterPositionDensity() 0 5 2
A merge() 0 9 2
A __construct() 0 5 1
A offsetGet() 0 3 1
1
<?php
2
3
namespace Spatie\CodeOutline\Elements;
4
5
use Spatie\Typed\Collection;
6
use Spatie\Typed\T;
7
8
class Line extends Collection
9
{
10
    public function __construct(int ...$values)
11
    {
12
        parent::__construct(T::int());
13
14
        $this->set($values);
15
    }
16
17
    public static function make(int $indentationCount, int $characterCount): self
18
    {
19
        $indentationValues = array_fill(0, $indentationCount, -1);
20
21
        $characterValues = array_fill(0, $characterCount, 1);
22
23
        $lineValues = array_merge($indentationValues, $characterValues);
24
25
        return new self(...$lineValues);
26
    }
27
28
    public function merge(self $line): self
29
    {
30
        $mergedLine = clone $this;
31
32
        foreach ($line as $position => $value) {
33
            $mergedLine[$position] = ($this[$position] ?? 0) + $value;
34
        }
35
36
        return $mergedLine;
37
    }
38
39
    public function getMaximumCharacterPositionDensity(): int
40
    {
41
        return $this->count()
42
            ? max($this->data)
43
            : 0;
44
    }
45
46
    public function offsetGet($offset): int
47
    {
48
        return parent::offsetGet($offset);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::offsetGet($offset) could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
49
    }
50
}
51