Move files and adjust namespaces
This commit is contained in:
53
src/Entity/Trait/MappableTrait.php
Normal file
53
src/Entity/Trait/MappableTrait.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\GeocodeBundle\Entity\Trait;
|
||||
|
||||
/**
|
||||
* Allows an entity to be mapped via latitude and longitude coordinates
|
||||
*
|
||||
* Use MappableInterface
|
||||
*
|
||||
* @package Pcm\GeocodeBundle
|
||||
*/
|
||||
trait MappableTrait
|
||||
{
|
||||
private ?float $latitude = null;
|
||||
|
||||
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