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
*
* @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);

View File

@ -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'];
}
}