From cf2792ce4590de96633d1943baeed87325376435 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Thu, 26 Oct 2023 17:21:15 +0200 Subject: [PATCH] Rename method - SizeInterface::getAspectRatio to SizeInterface::aspectRatio --- src/Geometry/Rectangle.php | 2 +- src/Geometry/Tools/RectangleResizer.php | 4 ++-- src/Interfaces/SizeInterface.php | 2 +- tests/Geometry/RectangleTest.php | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Geometry/Rectangle.php b/src/Geometry/Rectangle.php index 8734ec73..4e7df058 100644 --- a/src/Geometry/Rectangle.php +++ b/src/Geometry/Rectangle.php @@ -188,7 +188,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface ); } - public function getAspectRatio(): float + public function aspectRatio(): float { return $this->width() / $this->height(); } diff --git a/src/Geometry/Tools/RectangleResizer.php b/src/Geometry/Tools/RectangleResizer.php index 39450d53..20a0b2cc 100644 --- a/src/Geometry/Tools/RectangleResizer.php +++ b/src/Geometry/Tools/RectangleResizer.php @@ -77,7 +77,7 @@ class RectangleResizer return $size->width(); } - return (int) round($this->height * $size->getAspectRatio()); + return (int) round($this->height * $size->aspectRatio()); } protected function getProportionalHeight(SizeInterface $size): int @@ -86,7 +86,7 @@ class RectangleResizer return $size->height(); } - return (int) round($this->width / $size->getAspectRatio()); + return (int) round($this->width / $size->aspectRatio()); } public function resize(SizeInterface $size): SizeInterface diff --git a/src/Interfaces/SizeInterface.php b/src/Interfaces/SizeInterface.php index 8229610d..1dda4b19 100644 --- a/src/Interfaces/SizeInterface.php +++ b/src/Interfaces/SizeInterface.php @@ -10,7 +10,7 @@ interface SizeInterface public function setWidth(int $width): SizeInterface; public function setHeight(int $height): SizeInterface; public function setPivot(PointInterface $pivot): SizeInterface; - public function getAspectRatio(): float; + public function aspectRatio(): float; public function fitsInto(SizeInterface $size): bool; public function isLandscape(): bool; public function isPortrait(): bool; diff --git a/tests/Geometry/RectangleTest.php b/tests/Geometry/RectangleTest.php index 06ff057e..58f30c19 100644 --- a/tests/Geometry/RectangleTest.php +++ b/tests/Geometry/RectangleTest.php @@ -50,13 +50,13 @@ class RectangleTest extends TestCase public function testGetAspectRatio() { $size = new Rectangle(800, 600); - $this->assertEquals(1.333, round($size->getAspectRatio(), 3)); + $this->assertEquals(1.333, round($size->aspectRatio(), 3)); $size = new Rectangle(100, 100); - $this->assertEquals(1, $size->getAspectRatio()); + $this->assertEquals(1, $size->aspectRatio()); $size = new Rectangle(1920, 1080); - $this->assertEquals(1.778, round($size->getAspectRatio(), 3)); + $this->assertEquals(1.778, round($size->aspectRatio(), 3)); } public function testFitsInto()