Fix enum/location

This commit is contained in:
Dennis Eichhorn 2023-05-24 18:05:49 +00:00
parent 3e3be15c13
commit b3663ac127
2 changed files with 6 additions and 40 deletions

View File

@ -82,14 +82,12 @@ abstract class Enum
* *
* @return mixed * @return mixed
* *
* @throws \UnexpectedValueException throws this exception if the constant is not defined in the enum class
*
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getByName(string $name) : mixed public static function getByName(string $name) : mixed
{ {
if (!self::isValidName($name)) { if (!self::isValidName($name)) {
throw new \UnexpectedValueException($name); return null;
} }
return \constant('static::' . $name); return \constant('static::' . $name);

View File

@ -57,7 +57,7 @@ class Location implements \JsonSerializable, SerializableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $country = ISO3166TwoEnum::_XXX; public string $country = ISO3166TwoEnum::_XXX;
/** /**
* Street & district. * Street & district.
@ -73,7 +73,7 @@ class Location implements \JsonSerializable, SerializableInterface
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected int $type = AddressType::HOME; public int $type = AddressType::HOME;
/** /**
* State. * State.
@ -83,13 +83,9 @@ class Location implements \JsonSerializable, SerializableInterface
*/ */
public string $state = ''; public string $state = '';
/** public float $lat = 0.0;
* Geo coordinates.
* public float $lon = 0.0;
* @var float[]
* @since 1.0.0
*/
protected array $geo = ['lat' => 0, 'long' => 0];
/** /**
* Get location id * Get location id
@ -155,32 +151,6 @@ class Location implements \JsonSerializable, SerializableInterface
$this->country = $country; $this->country = $country;
} }
/**
* Get geo location
*
* @return float[]
*
* @since 1.0.0
*/
public function getGeo() : array
{
return $this->geo;
}
/**
* Set geo location
*
* @param float[] $geo Geo location lat/long
*
* @return void
*
* @since 1.0.0
*/
public function setGeo(array $geo) : void
{
$this->geo = $geo;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -208,7 +178,6 @@ class Location implements \JsonSerializable, SerializableInterface
'country' => $this->country, 'country' => $this->country,
'address' => $this->address, 'address' => $this->address,
'state' => $this->state, 'state' => $this->state,
'geo' => $this->geo,
]; ];
} }
@ -232,6 +201,5 @@ class Location implements \JsonSerializable, SerializableInterface
$this->country = $data['country']; $this->country = $data['country'];
$this->address = $data['address']; $this->address = $data['address'];
$this->state = $data['state']; $this->state = $data['state'];
$this->geo = $data['geo'];
} }
} }