| Total Complexity | 4 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 5 | class Present |
||
| 6 | { |
||
| 7 | /** @var int */ |
||
| 8 | private int $height; |
||
| 9 | |||
| 10 | /** @var int */ |
||
| 11 | private int $width; |
||
| 12 | |||
| 13 | /** @var int */ |
||
| 14 | private int $length; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param int $height |
||
| 18 | * @param int $width |
||
| 19 | * @param int $length |
||
| 20 | */ |
||
| 21 | public function __construct(int $height, int $width, int $length) |
||
| 22 | { |
||
| 23 | $this->height = $height; |
||
| 24 | $this->width = $width; |
||
| 25 | $this->length = $length; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $dimensions |
||
| 30 | * @return Present |
||
| 31 | */ |
||
| 32 | public static function fromString(string $dimensions): Present |
||
| 33 | { |
||
| 34 | list($height, $width, $length) = explode('x', $dimensions); |
||
| 35 | return new Present(intval($height), intval($width), intval($length)); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** @return int */ |
||
| 39 | public function getSurfaceArea(): int |
||
| 40 | { |
||
| 41 | $surfaceArea = (2 * $this->length * $this->width) |
||
| 42 | + (2 * $this->width * $this->height) |
||
| 43 | + (2 * $this->height * $this->length); |
||
| 44 | |||
| 45 | return $surfaceArea; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** @return int */ |
||
| 49 | public function getSmallestSideArea(): int |
||
| 57 | } |
||
| 58 | } |
||
| 59 |