From 4a301dcda07ff6a0d19734847d1f9bb82ac1f81c Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Thu, 26 Oct 2023 17:24:04 +0200 Subject: [PATCH] Rename method - SizeInterface::getRelativePositionTo to SizeInterface::relativePositionTo --- src/Drivers/Gd/Modifiers/PlaceModifier.php | 2 +- src/Drivers/Imagick/Modifiers/PlaceModifier.php | 2 +- src/Geometry/Rectangle.php | 4 ++-- src/Interfaces/SizeInterface.php | 2 +- tests/Geometry/RectangleTest.php | 10 +++++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Drivers/Gd/Modifiers/PlaceModifier.php b/src/Drivers/Gd/Modifiers/PlaceModifier.php index a999f2e5..a312536b 100644 --- a/src/Drivers/Gd/Modifiers/PlaceModifier.php +++ b/src/Drivers/Gd/Modifiers/PlaceModifier.php @@ -51,6 +51,6 @@ class PlaceModifier implements ModifierInterface $image_size = $image->size()->movePivot($this->position, $this->offset_x, $this->offset_y); $watermark_size = $watermark->size()->movePivot($this->position); - return $image_size->getRelativePositionTo($watermark_size); + return $image_size->relativePositionTo($watermark_size); } } diff --git a/src/Drivers/Imagick/Modifiers/PlaceModifier.php b/src/Drivers/Imagick/Modifiers/PlaceModifier.php index 4bdc555d..ba537431 100644 --- a/src/Drivers/Imagick/Modifiers/PlaceModifier.php +++ b/src/Drivers/Imagick/Modifiers/PlaceModifier.php @@ -44,6 +44,6 @@ class PlaceModifier implements ModifierInterface $image_size = $image->size()->movePivot($this->position, $this->offset_x, $this->offset_y); $watermark_size = $watermark->size()->movePivot($this->position); - return $image_size->getRelativePositionTo($watermark_size); + return $image_size->relativePositionTo($watermark_size); } } diff --git a/src/Geometry/Rectangle.php b/src/Geometry/Rectangle.php index 43e7e1be..b955f5e0 100644 --- a/src/Geometry/Rectangle.php +++ b/src/Geometry/Rectangle.php @@ -167,7 +167,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface $reference->movePivot($position); $this->movePivot($position)->setPivot( - $reference->getRelativePositionTo($this) + $reference->relativePositionTo($this) ); return $this; @@ -180,7 +180,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface * @param SizeInterface $rectangle * @return PointInterface */ - public function getRelativePositionTo(SizeInterface $rectangle): PointInterface + public function relativePositionTo(SizeInterface $rectangle): PointInterface { return new Point( $this->pivot()->getX() - $rectangle->pivot()->getX(), diff --git a/src/Interfaces/SizeInterface.php b/src/Interfaces/SizeInterface.php index aa866645..d30564c2 100644 --- a/src/Interfaces/SizeInterface.php +++ b/src/Interfaces/SizeInterface.php @@ -16,7 +16,7 @@ interface SizeInterface public function isPortrait(): bool; public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0): SizeInterface; public function alignPivotTo(SizeInterface $size, string $position): SizeInterface; - public function getRelativePositionTo(SizeInterface $size): PointInterface; + public function relativePositionTo(SizeInterface $size): PointInterface; public function resize(?int $width = null, ?int $height = null): SizeInterface; public function resizeDown(?int $width = null, ?int $height = null): SizeInterface; public function scale(?int $width = null, ?int $height = null): SizeInterface; diff --git a/tests/Geometry/RectangleTest.php b/tests/Geometry/RectangleTest.php index 0df4f261..a7ccffa4 100644 --- a/tests/Geometry/RectangleTest.php +++ b/tests/Geometry/RectangleTest.php @@ -209,7 +209,7 @@ class RectangleTest extends TestCase $input = new Rectangle(200, 100); $container->movePivot('top-left'); $input->movePivot('top-left'); - $pos = $container->getRelativePositionTo($input); + $pos = $container->relativePositionTo($input); $this->assertEquals(0, $pos->getX()); $this->assertEquals(0, $pos->getY()); @@ -217,7 +217,7 @@ class RectangleTest extends TestCase $input = new Rectangle(200, 100); $container->movePivot('center'); $input->movePivot('top-left'); - $pos = $container->getRelativePositionTo($input); + $pos = $container->relativePositionTo($input); $this->assertEquals(400, $pos->getX()); $this->assertEquals(300, $pos->getY()); @@ -225,7 +225,7 @@ class RectangleTest extends TestCase $input = new Rectangle(200, 100); $container->movePivot('bottom-right'); $input->movePivot('top-right'); - $pos = $container->getRelativePositionTo($input); + $pos = $container->relativePositionTo($input); $this->assertEquals(600, $pos->getX()); $this->assertEquals(600, $pos->getY()); @@ -233,7 +233,7 @@ class RectangleTest extends TestCase $input = new Rectangle(200, 100); $container->movePivot('center'); $input->movePivot('center'); - $pos = $container->getRelativePositionTo($input); + $pos = $container->relativePositionTo($input); $this->assertEquals(300, $pos->getX()); $this->assertEquals(250, $pos->getY()); @@ -241,7 +241,7 @@ class RectangleTest extends TestCase $input = new Rectangle(100, 100); $container->movePivot('center'); $input->movePivot('center'); - $pos = $container->getRelativePositionTo($input); + $pos = $container->relativePositionTo($input); $this->assertEquals(0, $pos->getX()); $this->assertEquals(50, $pos->getY()); }