2016-07-20 10:35:46 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-07-20 10:35:46 +03:00
|
|
|
namespace Shlinkio\Shlink\Core\Entity;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2017-10-12 11:13:20 +03:00
|
|
|
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
2016-07-20 10:35:46 +03:00
|
|
|
use Zend\Stdlib\ArraySerializableInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class VisitLocation
|
|
|
|
* @author
|
|
|
|
* @link
|
|
|
|
*
|
|
|
|
* @ORM\Entity()
|
|
|
|
* @ORM\Table(name="visit_locations")
|
|
|
|
*/
|
|
|
|
class VisitLocation extends AbstractEntity implements ArraySerializableInterface, \JsonSerializable
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $countryCode;
|
2016-07-20 10:35:46 +03:00
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $countryName;
|
2016-07-20 10:35:46 +03:00
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $regionName;
|
2016-07-20 10:35:46 +03:00
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $cityName;
|
2016-07-20 10:35:46 +03:00
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $latitude;
|
2016-07-20 10:35:46 +03:00
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $longitude;
|
2016-07-20 10:35:46 +03:00
|
|
|
/**
|
|
|
|
* @var string
|
2016-07-20 20:00:23 +03:00
|
|
|
* @ORM\Column(nullable=true)
|
2016-07-20 10:35:46 +03:00
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
private $timezone;
|
2016-07-20 10:35:46 +03:00
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getCountryCode(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->countryCode ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setCountryCode(string $countryCode)
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->countryCode = $countryCode;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getCountryName(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->countryName ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setCountryName(string $countryName): self
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->countryName = $countryName;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getRegionName(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->regionName ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setRegionName(string $regionName): self
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->regionName = $regionName;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getCityName(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->cityName ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setCityName(string $cityName): self
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->cityName = $cityName;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getLatitude(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->latitude ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setLatitude(string $latitude): self
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->latitude = $latitude;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getLongitude(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->longitude ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setLongitude(string $longitude): self
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->longitude = $longitude;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getTimezone(): string
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
return $this->timezone ?? '';
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function setTimezone(string $timezone): self
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
$this->timezone = $timezone;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Exchange internal values from provided array
|
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
public function exchangeArray(array $array): void
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('country_code', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setCountryCode((string) $array['country_code']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('country_name', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setCountryName((string) $array['country_name']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('region_name', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setRegionName((string) $array['region_name']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('city', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setCityName((string) $array['city']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('latitude', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setLatitude((string) $array['latitude']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('longitude', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setLongitude((string) $array['longitude']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
2018-09-15 11:03:42 +03:00
|
|
|
if (\array_key_exists('time_zone', $array)) {
|
2018-10-16 19:21:51 +03:00
|
|
|
$this->setTimezone((string) $array['time_zone']);
|
2016-07-20 10:35:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an array representation of the object
|
|
|
|
*/
|
2018-09-15 11:03:42 +03:00
|
|
|
public function getArrayCopy(): array
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'countryCode' => $this->countryCode,
|
|
|
|
'countryName' => $this->countryName,
|
|
|
|
'regionName' => $this->regionName,
|
|
|
|
'cityName' => $this->cityName,
|
|
|
|
'latitude' => $this->latitude,
|
|
|
|
'longitude' => $this->longitude,
|
|
|
|
'timezone' => $this->timezone,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-09-15 11:03:42 +03:00
|
|
|
public function jsonSerialize(): array
|
2016-07-20 10:35:46 +03:00
|
|
|
{
|
|
|
|
return $this->getArrayCopy();
|
|
|
|
}
|
|
|
|
}
|