From ec1fead71fecbdcc2117194a72ea9d85b4051b55 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Tue, 2 Jan 2024 13:03:44 +0100 Subject: [PATCH] Throw exceptions if resizer receives unvalid values --- src/Geometry/Tools/RectangleResizer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Geometry/Tools/RectangleResizer.php b/src/Geometry/Tools/RectangleResizer.php index 935e1af4..0f78f11c 100644 --- a/src/Geometry/Tools/RectangleResizer.php +++ b/src/Geometry/Tools/RectangleResizer.php @@ -12,7 +12,17 @@ class RectangleResizer protected ?int $width = null, protected ?int $height = null, ) { - // + if (is_int($width) && $width < 1) { + throw new GeometryException( + 'The width you specify must be greater than or equal to 1.' + ); + } + + if (is_int($height) && $height < 1) { + throw new GeometryException( + 'The height you specify must be greater than or equal to 1.' + ); + } } public static function to(...$arguments): self