From 44fd6969923d2e84207ef7c74a726c337db4ceae Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 3 Aug 2023 13:41:20 +0100 Subject: [PATCH] AxisAlignedBB: modernize extend() code --- src/AxisAlignedBB.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/AxisAlignedBB.php b/src/AxisAlignedBB.php index dedc7b7..b96e292 100644 --- a/src/AxisAlignedBB.php +++ b/src/AxisAlignedBB.php @@ -185,21 +185,15 @@ public function contractedCopy(float $x, float $y, float $z) : AxisAlignedBB{ * @throws \InvalidArgumentException */ public function extend(int $face, float $distance) : AxisAlignedBB{ - if($face === Facing::DOWN){ - $this->minY -= $distance; - }elseif($face === Facing::UP){ - $this->maxY += $distance; - }elseif($face === Facing::NORTH){ - $this->minZ -= $distance; - }elseif($face === Facing::SOUTH){ - $this->maxZ += $distance; - }elseif($face === Facing::WEST){ - $this->minX -= $distance; - }elseif($face === Facing::EAST){ - $this->maxX += $distance; - }else{ - throw new \InvalidArgumentException("Invalid face $face"); - } + match($face){ + Facing::DOWN => $this->minY -= $distance, + Facing::UP => $this->maxY += $distance, + Facing::NORTH => $this->minZ -= $distance, + Facing::SOUTH => $this->maxZ += $distance, + Facing::WEST => $this->minX -= $distance, + Facing::EAST => $this->maxX += $distance, + default => throw new \InvalidArgumentException("Invalid face $face"), + }; return $this; }