From 16cc19a5d0ac0c19df3e684d213fec0e4ff34201 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Tue, 19 Jul 2022 19:29:13 +0200 Subject: [PATCH] Remove unused methods from Polygon::class - Polygon::alignPivot() - Polygon::valignPivot() --- src/Geometry/Polygon.php | 63 ---------------------------------- tests/Geometry/PolygonTest.php | 36 ------------------- 2 files changed, 99 deletions(-) diff --git a/src/Geometry/Polygon.php b/src/Geometry/Polygon.php index f7d1eef3..71291f61 100644 --- a/src/Geometry/Polygon.php +++ b/src/Geometry/Polygon.php @@ -254,69 +254,6 @@ class Polygon implements Countable, ArrayAccess ); } - /** - * Align pivot point to given horizontal position - * - * @param string $position - * @return Polygon - */ - public function alignPivot(string $position): self - { - switch (strtolower($position)) { - case 'center': - $this->pivot->setX( - intval(($this->getMostRightPoint()->getX() + $this->getMostLeftPoint()->getX()) / 2) - ); - break; - - case 'right': - $this->pivot->setX( - $this->getMostRightPoint()->getX() - ); - break; - - case 'left': - $this->pivot->setX( - $this->getMostLeftPoint()->getX() - ); - break; - } - - return $this; - } - - /** - * Align pivot point to given vertical position - * - * @param string $position - * @return Polygon - */ - public function valignPivot(string $position): self - { - switch (strtolower($position)) { - case 'center': - case 'middle': - $this->pivot->setY( - intval(($this->getMostTopPoint()->getY() + $this->getMostBottomPoint()->getY()) / 2) - ); - break; - - case 'top': - $this->pivot->setY( - $this->getMostTopPoint()->getY() - ); - break; - - case 'bottom': - $this->pivot->setY( - $this->getMostBottomPoint()->getY() - ); - break; - } - - return $this; - } - /** * Align all points of polygon horizontally to given position around pivot point * diff --git a/tests/Geometry/PolygonTest.php b/tests/Geometry/PolygonTest.php index 3ed904de..8428a0cf 100644 --- a/tests/Geometry/PolygonTest.php +++ b/tests/Geometry/PolygonTest.php @@ -125,42 +125,6 @@ class PolygonTest extends TestCase $this->assertInstanceOf(Point::class, $poly->getPivotPoint()); } - public function testAlignPivot(): void - { - $poly = new Polygon([ - new Point(12, 45), - new Point(-24, -49), - new Point(3, 566), - ]); - - $this->assertEquals(0, $poly->getPivotPoint()->getX()); - $this->assertEquals(0, $poly->getPivotPoint()->getY()); - - $result = $poly->alignPivot('center'); - $this->assertInstanceOf(Polygon::class, $result); - - $this->assertEquals(-6, $result->getPivotPoint()->getX()); - $this->assertEquals(0, $result->getPivotPoint()->getY()); - } - - public function testValignPivot(): void - { - $poly = new Polygon([ - new Point(12, 45), - new Point(-24, -50), - new Point(3, 566), - ]); - - $this->assertEquals(0, $poly->getPivotPoint()->getX()); - $this->assertEquals(0, $poly->getPivotPoint()->getY()); - - $result = $poly->valignPivot('middle'); - $this->assertInstanceOf(Polygon::class, $result); - - $this->assertEquals(0, $result->getPivotPoint()->getX()); - $this->assertEquals(258, $result->getPivotPoint()->getY()); - } - public function testGetMostLeftPoint(): void { $poly = new Polygon([