phpOMS/Datatypes/Location.php

260 lines
4.6 KiB
PHP

<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Datatypes;
use phpOMS\Contract\JsonableInterface;
/**
* Location class.
*
* @category Framework
* @package phpOMS\Datatypes
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Location implements JsonableInterface
{
/**
* Zip or postal.
*
* @var string
* @since 1.0.0
*/
private $postal = '';
/**
* Name of city.
*
* @var string
* @since 1.0.0
*/
private $city = '';
/**
* Name of the country.
*
* @var string
* @since 1.0.0
*/
private $country = '';
/**
* Street & district.
*
* @var string
* @since 1.0.0
*/
private $address = '';
/**
* State.
*
* @var string
* @since 1.0.0
*/
private $state = '';
/**
* Geo coordinates.
*
* @var float[]
* @since 1.0.0
*/
private $geo = ['lat' => 0, 'long' => 0];
/**
* Constructor.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct()
{
}
/**
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getPostal() : string
{
return $this->postal;
}
/**
* @param string $postal
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setPostal(string $postal)
{
$this->postal = $postal;
}
/**
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getCity() : string
{
return $this->city;
}
/**
* @param string $city
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setCity(string $city)
{
$this->city = $city;
}
/**
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getCountry() : string
{
return $this->country;
}
/**
* @param string $country
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setCountry(string $country)
{
$this->country = $country;
}
/**
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getAddress() : string
{
return $this->address;
}
/**
* @param string $address
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setAddress(string $address)
{
$this->address = $address;
}
/**
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getState() : string
{
return $this->state;
}
/**
* @param string $state
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setState(string $state)
{
$this->state = $state;
}
/**
* @return float[]
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getGeo() : array
{
return $this->geo;
}
/**
* @param float[] $geo
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setGeo(array $geo)
{
$this->geo = $geo;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'postal' => $this->postal,
'city' => $this->city,
'country' => $this->country,
'address' => $this->address,
'state' => $this->state,
'geo' => $this->geo,
];
}
/**
* {@inheritdoc}
*/
public function toJson(int $option = 0) : string
{
return json_encode($this->toArray());
}
}