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

182 lines
4.1 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;
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
* @ORM\Column(nullable=true)
2016-07-20 10:35:46 +03:00
*/
private $countryCode;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true)
2016-07-20 10:35:46 +03:00
*/
private $countryName;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true)
2016-07-20 10:35:46 +03:00
*/
private $regionName;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true)
2016-07-20 10:35:46 +03:00
*/
private $cityName;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true)
2016-07-20 10:35:46 +03:00
*/
private $latitude;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true)
2016-07-20 10:35:46 +03:00
*/
private $longitude;
2016-07-20 10:35:46 +03:00
/**
* @var string
* @ORM\Column(nullable=true)
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($array['country_code']);
2016-07-20 10:35:46 +03:00
}
if (\array_key_exists('country_name', $array)) {
$this->setCountryName($array['country_name']);
2016-07-20 10:35:46 +03:00
}
if (\array_key_exists('region_name', $array)) {
$this->setRegionName($array['region_name']);
2016-07-20 10:35:46 +03:00
}
if (\array_key_exists('city', $array)) {
$this->setCityName($array['city']);
2016-07-20 10:35:46 +03:00
}
if (\array_key_exists('latitude', $array)) {
2016-07-20 10:35:46 +03:00
$this->setLatitude($array['latitude']);
}
if (\array_key_exists('longitude', $array)) {
2016-07-20 10:35:46 +03:00
$this->setLongitude($array['longitude']);
}
if (\array_key_exists('time_zone', $array)) {
$this->setTimezone($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();
}
}