From b3663ac12729c2cf1f47d6b257fc840bf5feeeba Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 24 May 2023 18:05:49 +0000 Subject: [PATCH] Fix enum/location --- Stdlib/Base/Enum.php | 4 +--- Stdlib/Base/Location.php | 42 +++++----------------------------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/Stdlib/Base/Enum.php b/Stdlib/Base/Enum.php index d38669fc8..483a92f7e 100755 --- a/Stdlib/Base/Enum.php +++ b/Stdlib/Base/Enum.php @@ -82,14 +82,12 @@ abstract class Enum * * @return mixed * - * @throws \UnexpectedValueException throws this exception if the constant is not defined in the enum class - * * @since 1.0.0 */ public static function getByName(string $name) : mixed { if (!self::isValidName($name)) { - throw new \UnexpectedValueException($name); + return null; } return \constant('static::' . $name); diff --git a/Stdlib/Base/Location.php b/Stdlib/Base/Location.php index 4913b4368..81e590108 100755 --- a/Stdlib/Base/Location.php +++ b/Stdlib/Base/Location.php @@ -57,7 +57,7 @@ class Location implements \JsonSerializable, SerializableInterface * @var string * @since 1.0.0 */ - protected string $country = ISO3166TwoEnum::_XXX; + public string $country = ISO3166TwoEnum::_XXX; /** * Street & district. @@ -73,7 +73,7 @@ class Location implements \JsonSerializable, SerializableInterface * @var int * @since 1.0.0 */ - protected int $type = AddressType::HOME; + public int $type = AddressType::HOME; /** * State. @@ -83,13 +83,9 @@ class Location implements \JsonSerializable, SerializableInterface */ public string $state = ''; - /** - * Geo coordinates. - * - * @var float[] - * @since 1.0.0 - */ - protected array $geo = ['lat' => 0, 'long' => 0]; + public float $lat = 0.0; + + public float $lon = 0.0; /** * Get location id @@ -155,32 +151,6 @@ class Location implements \JsonSerializable, SerializableInterface $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} */ @@ -208,7 +178,6 @@ class Location implements \JsonSerializable, SerializableInterface 'country' => $this->country, 'address' => $this->address, 'state' => $this->state, - 'geo' => $this->geo, ]; } @@ -232,6 +201,5 @@ class Location implements \JsonSerializable, SerializableInterface $this->country = $data['country']; $this->address = $data['address']; $this->state = $data['state']; - $this->geo = $data['geo']; } }