Total Complexity | 7 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class Line extends Collection |
||
9 | { |
||
10 | public function __construct(int ...$values) |
||
11 | { |
||
12 | parent::__construct(T::int(), $values); |
||
13 | } |
||
14 | |||
15 | public static function make(int $indentationCount, int $characterCount): Line |
||
16 | { |
||
17 | $indentationValues = array_fill(0, $indentationCount, -1); |
||
18 | |||
19 | $characterValues = array_fill(0, $characterCount, 1); |
||
20 | |||
21 | $lineValues = array_merge($indentationValues, $characterValues); |
||
22 | |||
23 | return new self(...$lineValues); |
||
24 | } |
||
25 | |||
26 | public function merge(Line $line): Line |
||
27 | { |
||
28 | $mergedLine = clone $this; |
||
29 | |||
30 | foreach ($line as $position => $value) { |
||
31 | $mergedLine[$position] = ($this[$position] ?? 0) + $value; |
||
32 | } |
||
33 | |||
34 | return $mergedLine; |
||
35 | } |
||
36 | |||
37 | public function getMaximumCharacterPositionDensity(): int |
||
42 | } |
||
43 | |||
44 | public function offsetGet($offset): int |
||
47 | } |
||
48 | } |
||
49 |