| Total Complexity | 9 |
| Total Lines | 49 |
| 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()); |
||
| 13 | |||
| 14 | $this->set($values); |
||
| 15 | } |
||
| 16 | |||
| 17 | public static function make(int $indentationCount, int $characterCount): self |
||
| 26 | } |
||
| 27 | |||
| 28 | public function merge(Line $line): Line |
||
| 29 | { |
||
| 30 | $mergedLine = new Line(); |
||
| 31 | |||
| 32 | $largestLine = $this->count() > $line->count() |
||
| 33 | ? $this |
||
| 34 | : $line; |
||
| 35 | |||
| 36 | foreach ($largestLine as $position => $value) { |
||
| 37 | $mergedLine[$position] = ($this[$position] ?? 0) + ($line[$position] ?? 0); |
||
| 38 | } |
||
| 39 | |||
| 40 | if (! $largestLine->count()) { |
||
| 41 | return new EmptyLine(); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $mergedLine; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getMaximumCharacterPositionDensity(): int |
||
| 52 | } |
||
| 53 | |||
| 54 | public function offsetGet($offset): int |
||
| 59 |