mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
more final and edge case fixes
This commit is contained in:
parent
150f86df4a
commit
7e831763e5
|
|
@ -28,7 +28,7 @@ use phpOMS\Uri\Http;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Currency
|
||||
final class Currency
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -98,21 +98,25 @@ class Currency
|
|||
*/
|
||||
public static function getEcbEuroRates() : array
|
||||
{
|
||||
if (!isset(self::$ecbCurrencies)) {
|
||||
if (!empty(self::$ecbCurrencies)) {
|
||||
$request = new Request(new Http('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'));
|
||||
$request->setMethod(RequestMethod::GET);
|
||||
|
||||
$xml = new \SimpleXMLElement(Rest::request($request)->getBody());
|
||||
try {
|
||||
$xml = new \SimpleXMLElement(Rest::request($request)->getBody());
|
||||
|
||||
if (!isset($xml->Cube)) {
|
||||
throw new \Exception('Invalid xml path');
|
||||
}
|
||||
if (!isset($xml->Cube)) {
|
||||
throw new \Exception('Invalid xml path');
|
||||
}
|
||||
|
||||
$node = $xml->Cube->Cube->Cube;
|
||||
self::$ecbCurrencies = [];
|
||||
$node = $xml->Cube->Cube->Cube;
|
||||
self::$ecbCurrencies = [];
|
||||
|
||||
foreach ($node as $key => $value) {
|
||||
self::$ecbCurrencies[\strtoupper((string) $value->attributes()['currency'])] = (float) $value->attributes()['rate'];
|
||||
foreach ($node as $key => $value) {
|
||||
self::$ecbCurrencies[\strtoupper((string) $value->attributes()['currency'])] = (float) $value->attributes()['rate'];
|
||||
}
|
||||
} catch (\Throwable $t) {
|
||||
self::$ecbCurrencies = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace phpOMS\Utils\Converter;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class File
|
||||
final class File
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace phpOMS\Utils\Converter;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Ip
|
||||
final class Ip
|
||||
{
|
||||
public const IP_TABLE_ITERATIONS = 100;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace phpOMS\Utils\Converter;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Measurement
|
||||
final class Measurement
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace phpOMS\Utils\Converter;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Numeric
|
||||
final class Numeric
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user