Rename Mappable stuff to Geocode stuff, change dir structure
This commit is contained in:
56
src/Trait/Entity/GeocodeTrait.php
Normal file
56
src/Trait/Entity/GeocodeTrait.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\GeocodeBundle\Trait\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Implementation of {@see Pcm\GeocodeBundle\Interface\Entity\GeocodeInterface}
|
||||
*
|
||||
* @package Pcm\GeocodeBundle
|
||||
*/
|
||||
trait GeocodeTrait
|
||||
{
|
||||
#[ORM\Column(type: 'decimal', precision: 10, scale: 6, nullable: true)]
|
||||
private ?float $latitude = null;
|
||||
|
||||
#[ORM\Column(type: 'decimal', precision: 10, scale: 6, nullable: true)]
|
||||
private ?float $longitude = null;
|
||||
|
||||
public function getLatitude(): ?float
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function getLongitude(): ?float
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
|
||||
public function setLatitude(float $lat): self
|
||||
{
|
||||
$this->latitude = $lat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLongitude(float $lon): self
|
||||
{
|
||||
$this->longitude = $lon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if both latitude and longitude have been set
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGeocoded(): bool
|
||||
{
|
||||
return null !== $this->getLatitude() && null !== $this->getLongitude();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user