| Total Complexity | 5 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class Day2 implements Day |
||
| 10 | { |
||
| 11 | /** @var array<string> */ |
||
| 12 | private array $dimensions = []; |
||
| 13 | |||
| 14 | /** @return void */ |
||
| 15 | public function loadInput(): void |
||
| 16 | { |
||
| 17 | $filepath = __DIR__ . "/input.txt"; |
||
| 18 | $file = file($filepath); |
||
| 19 | |||
| 20 | if (!is_array($file)) { |
||
| 21 | throw new Exception("Could not open input file: {$filepath}"); |
||
| 22 | } |
||
| 23 | |||
| 24 | $this->dimensions = $file; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** @return void */ |
||
| 28 | public function solve(): void |
||
| 29 | { |
||
| 30 | $amountWrappingPaper = 0; |
||
| 31 | foreach ($this->dimensions as $dimension) { |
||
| 32 | $present = Present::fromString($dimension); |
||
| 33 | $amountWrappingPaper += $present->getSurfaceArea(); |
||
| 34 | $amountWrappingPaper += $present->getSmallestSideArea(); |
||
| 35 | } |
||
| 36 | |||
| 37 | printf("The total amount of wrapping paper is: %s\n", $amountWrappingPaper); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** @return array<string> */ |
||
| 41 | public function getDimensions(): array |
||
| 44 | } |
||
| 45 | } |
||
| 46 |