From 8b662ebfa3cac7735c06b66731956c80e7c17f27 Mon Sep 17 00:00:00 2001 From: brabli <67018167+Brabli@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:25:03 +0100 Subject: [PATCH] Rename Mappable stuff to Geocode stuff, change dir structure --- .../Entity/GeocodeInterface.php} | 4 ++-- .../Entity/GeocodeTrait.php} | 9 ++++----- tests/Service/GeocodeTest.php | 10 +++++----- ...pableTraitTest.php => GeocodeTraitTest.php} | 18 +++++++++--------- 4 files changed, 20 insertions(+), 21 deletions(-) rename src/{Entity/Interface/MappableInterface.php => Interface/Entity/GeocodeInterface.php} (78%) rename src/{Entity/Trait/MappableTrait.php => Trait/Entity/GeocodeTrait.php} (85%) rename tests/Trait/{MappableTraitTest.php => GeocodeTraitTest.php} (78%) diff --git a/src/Entity/Interface/MappableInterface.php b/src/Interface/Entity/GeocodeInterface.php similarity index 78% rename from src/Entity/Interface/MappableInterface.php rename to src/Interface/Entity/GeocodeInterface.php index 99d2d73..a94d4fa 100644 --- a/src/Entity/Interface/MappableInterface.php +++ b/src/Interface/Entity/GeocodeInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Pcm\GeocodeBundle\Entity\Interface; +namespace Pcm\GeocodeBundle\Interface\Entity; -interface MappableInterface +interface GeocodeInterface { public function getLatitude(): ?float; diff --git a/src/Entity/Trait/MappableTrait.php b/src/Trait/Entity/GeocodeTrait.php similarity index 85% rename from src/Entity/Trait/MappableTrait.php rename to src/Trait/Entity/GeocodeTrait.php index 89c3b65..1548b5b 100644 --- a/src/Entity/Trait/MappableTrait.php +++ b/src/Trait/Entity/GeocodeTrait.php @@ -2,18 +2,16 @@ declare(strict_types=1); -namespace Pcm\GeocodeBundle\Entity\Trait; +namespace Pcm\GeocodeBundle\Trait\Entity; use Doctrine\ORM\Mapping as ORM; /** - * Allows an entity to be mapped via latitude and longitude coordinates - * - * Use MappableInterface + * Implementation of {@see Pcm\GeocodeBundle\Interface\Entity\GeocodeInterface} * * @package Pcm\GeocodeBundle */ -trait MappableTrait +trait GeocodeTrait { #[ORM\Column(type: 'decimal', precision: 10, scale: 6, nullable: true)] private ?float $latitude = null; @@ -55,3 +53,4 @@ trait MappableTrait return null !== $this->getLatitude() && null !== $this->getLongitude(); } } + diff --git a/tests/Service/GeocodeTest.php b/tests/Service/GeocodeTest.php index 3d8b310..b70e32d 100644 --- a/tests/Service/GeocodeTest.php +++ b/tests/Service/GeocodeTest.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Pcm\GeocodeBundle\Tests; -use Pcm\GeocodeBundle\Entity\Interface\MappableInterface; -use Pcm\GeocodeBundle\Entity\Trait\MappableTrait; +use Pcm\GeocodeBundle\Interface\Entity\GeocodeInterface; +use Pcm\GeocodeBundle\Trait\Entity\GeocodeTrait; use Pcm\GeocodeBundle\Exception\ApiErrorException; use Pcm\GeocodeBundle\Exception\NoResultsFoundException; use Pcm\GeocodeBundle\Model\GeoCoordinates; @@ -69,11 +69,11 @@ final class GeocodeTest extends KernelTestCase $this->assertIsFloat($geoCoordinates->longitude); } - private function getMappableEntity(): MappableInterface + private function getGeocodableEntity(): GeocodeInterface { - return new class implements MappableInterface + return new class implements GeocodeInterface { - use MappableTrait; + use GeocodeTrait; }; } } diff --git a/tests/Trait/MappableTraitTest.php b/tests/Trait/GeocodeTraitTest.php similarity index 78% rename from tests/Trait/MappableTraitTest.php rename to tests/Trait/GeocodeTraitTest.php index 49a6436..fcc8cfd 100644 --- a/tests/Trait/MappableTraitTest.php +++ b/tests/Trait/GeocodeTraitTest.php @@ -4,15 +4,15 @@ declare(strict_types=1); namespace Pcm\GeocodeBundle\Tests; -use Pcm\GeocodeBundle\Entity\Interface\MappableInterface; -use Pcm\GeocodeBundle\Entity\Trait\MappableTrait; +use Pcm\GeocodeBundle\Interface\Entity\GeocodeInterface; +use Pcm\GeocodeBundle\Trait\Entity\GeocodeTrait; use PHPUnit\Framework\TestCase; -final class MappableTraitTest extends TestCase +final class GeocodeTraitTest extends TestCase { private const float COORD = 123.456; - private MappableInterface $obj; + private GeocodeInterface $obj; protected function setUp(): void { @@ -21,7 +21,7 @@ final class MappableTraitTest extends TestCase public function testSetLatitude(): void { - $this->assertInstanceOf(MappableInterface::class, $this->obj->setLatitude(self::COORD)); + $this->assertInstanceOf(GeocodeInterface::class, $this->obj->setLatitude(self::COORD)); } public function testGetLatitudeReturnsNull(): void @@ -37,7 +37,7 @@ final class MappableTraitTest extends TestCase public function testSetLongitude(): void { - $this->assertInstanceOf(MappableInterface::class, $this->obj->setLongitude(self::COORD)); + $this->assertInstanceOf(GeocodeInterface::class, $this->obj->setLongitude(self::COORD)); } public function testGetLongitudeReturnsNull(): void @@ -82,11 +82,11 @@ final class MappableTraitTest extends TestCase $this->assertTrue($this->obj->isGeocoded()); } - private function getTraitObject(): MappableInterface + private function getTraitObject(): GeocodeInterface { - return new class implements MappableInterface + return new class implements GeocodeInterface { - use MappableTrait; + use GeocodeTrait; }; } }