Files
pcm-geocode-bundle/src/Trait/Entity/GeocodeTrait.php
2024-10-09 16:03:18 +01:00

56 lines
1.2 KiB
PHP

<?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;
}
public function isGeocoded(): bool
{
$latIsntNull = null !== $this->getLatitude();
$longIsntNull = null !== $this->getLongitude();
$bothArentZero = !(0.0 === $this->getLatitude() && 0.0 === $this->getLongitude());
return $latIsntNull && $longIsntNull && $bothArentZero;
}
}