shlink/module/Core/src/Entity/VisitLocation.php

184 lines
4.3 KiB
PHP
Raw Normal View History

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;
use JsonSerializable;
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;
use function array_key_exists;
2016-07-20 10:35:46 +03:00
/**
* Class VisitLocation
* @author
* @link
*
* @ORM\Entity()
* @ORM\Table(name="visit_locations")
*/
class VisitLocation extends AbstractEntity implements ArraySerializableInterface, JsonSerializable
2016-07-20 10:35:46 +03:00
{
/**
* @var string
* @ORM\Column(nullable=true, name="country_code")
2016-07-20 10:35:46 +03:00
*/
private $countryCode;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true, name="country_name")
2016-07-20 10:35:46 +03:00
*/
private $countryName;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true, name="region_name")
2016-07-20 10:35:46 +03:00
*/
private $regionName;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true, name="city_name")
2016-07-20 10:35:46 +03:00
*/
private $cityName;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true, name="latitude")
2016-07-20 10:35:46 +03:00
*/
private $latitude;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true, name="longitude")
2016-07-20 10:35:46 +03:00
*/
private $longitude;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true, name="timezone")
2016-07-20 10:35:46 +03:00
*/
private $timezone;
2016-07-20 10:35:46 +03:00
public function getCountryCode(): string
2016-07-20 10:35:46 +03:00
{
return $this->countryCode ?? '';
2016-07-20 10:35:46 +03:00
}
public function setCountryCode(string $countryCode)
2016-07-20 10:35:46 +03:00
{
$this->countryCode = $countryCode;
return $this;
}
public function getCountryName(): string
2016-07-20 10:35:46 +03:00
{
return $this->countryName ?? '';
2016-07-20 10:35:46 +03:00
}
public function setCountryName(string $countryName): self
2016-07-20 10:35:46 +03:00
{
$this->countryName = $countryName;
return $this;
}
public function getRegionName(): string
2016-07-20 10:35:46 +03:00
{
return $this->regionName ?? '';
2016-07-20 10:35:46 +03:00
}
public function setRegionName(string $regionName): self
2016-07-20 10:35:46 +03:00
{
$this->regionName = $regionName;
return $this;
}
public function getCityName(): string
2016-07-20 10:35:46 +03:00
{
return $this->cityName ?? '';
2016-07-20 10:35:46 +03:00
}
public function setCityName(string $cityName): self
2016-07-20 10:35:46 +03:00
{
$this->cityName = $cityName;
return $this;
}
public function getLatitude(): string
2016-07-20 10:35:46 +03:00
{
return $this->latitude ?? '';
2016-07-20 10:35:46 +03:00
}
public function setLatitude(string $latitude): self
2016-07-20 10:35:46 +03:00
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): string
2016-07-20 10:35:46 +03:00
{
return $this->longitude ?? '';
2016-07-20 10:35:46 +03:00
}
public function setLongitude(string $longitude): self
2016-07-20 10:35:46 +03:00
{
$this->longitude = $longitude;
return $this;
}
public function getTimezone(): string
2016-07-20 10:35:46 +03:00
{
return $this->timezone ?? '';
2016-07-20 10:35:46 +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
*/
public function exchangeArray(array $array): void
2016-07-20 10:35:46 +03:00
{
if (array_key_exists('country_code', $array)) {
$this->setCountryCode((string) $array['country_code']);
2016-07-20 10:35:46 +03:00
}
if (array_key_exists('country_name', $array)) {
$this->setCountryName((string) $array['country_name']);
2016-07-20 10:35:46 +03:00
}
if (array_key_exists('region_name', $array)) {
$this->setRegionName((string) $array['region_name']);
2016-07-20 10:35:46 +03:00
}
if (array_key_exists('city', $array)) {
$this->setCityName((string) $array['city']);
2016-07-20 10:35:46 +03:00
}
if (array_key_exists('latitude', $array)) {
$this->setLatitude((string) $array['latitude']);
2016-07-20 10:35:46 +03:00
}
if (array_key_exists('longitude', $array)) {
$this->setLongitude((string) $array['longitude']);
2016-07-20 10:35:46 +03:00
}
if (array_key_exists('time_zone', $array)) {
$this->setTimezone((string) $array['time_zone']);
2016-07-20 10:35:46 +03:00
}
}
/**
* Return an array representation of the object
*/
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,
];
}
public function jsonSerialize(): array
2016-07-20 10:35:46 +03:00
{
return $this->getArrayCopy();
}
}