Skip to content
Code-Schnipsel Gruppen Projekte
Commit cf368687 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix(phpstan): update phive and refactor ERP Currency Handler

- Updated the version of phive to ^2.0.4 in the phars.xml file
- Refactored the ERP Currency Handler in the following ways:
  - Rearranged the argument order and types in createCurrency function
  - Removed unused languageData in createCurrency function
  - Updated createCurrency, deleteCurrency, updateCurrency to return void
  - Updated getDefaultCurrency to return Currency|null
  - Fixed getCurrency to handle `isset($currency['code'])`
  - Updated getCurrencies to handle `null | QUI\\Locale`
  - Standardized exception catch statements to `QUI\\Exception` without variable
  - Minor cleanups and formatting for increased readability
Übergeordneter c23a81e7
No related branches found
No related tags found
2 Merge Requests!54Update 'next-3.x' with latest changes from 'main',!53feat(Currency.js): get default currency
Pipeline #16541 bestanden mit Phase
in 2 Minuten und 14 Sekunden
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/>
<phar name="phpstan" version="^2.0.4" installed="2.0.4" location="./tools/phpstan" copy="false"/>
<phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/>
<phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
......
......@@ -57,19 +57,22 @@ public static function table(): string
* Create a new currency
*
* @param string $currency - currency code
* @param integer|float $rate - currency exchange rate, default = 1
* @param float|integer $rate - currency exchange rate, default = 1
* @param string $type (optional) - Currency type
* @throws QUI\Exception
*/
public static function createCurrency(string $currency, $rate = 1, string $type = self::CURRENCY_TYPE_DEFAULT)
{
public static function createCurrency(
string $currency,
float | int | string $rate = 1,
string $type = self::CURRENCY_TYPE_DEFAULT
): void {
QUI\Permissions\Permission::checkPermission('currency.create');
$Currency = null;
try {
$Currency = self::getCurrency($currency);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
if (!is_null($Currency)) {
......@@ -94,10 +97,6 @@ public static function createCurrency(string $currency, $rate = 1, string $type
]);
// create translations
$languageData = [
'datatype' => 'js,php'
];
$localeGroup = 'quiqqer/currency';
$localeText = 'currency.' . $currency . '.text';
$localeSign = 'currency.' . $currency . '.sign';
......@@ -123,7 +122,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type
'currency.' . $currency . '.text',
'quiqqer/currency'
);
} catch (QUI\Exception $e) {
} catch (QUI\Exception) {
}
if (!empty($textData)) {
......@@ -142,7 +141,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type
'currency.' . $currency . '.sign',
'quiqqer/currency'
);
} catch (QUI\Exception $e) {
} catch (QUI\Exception) {
}
......@@ -164,7 +163,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type
* @param string $currency - currency code
* @throws QUI\Exception
*/
public static function deleteCurrency(string $currency)
public static function deleteCurrency(string $currency): void
{
QUI\Permissions\Permission::checkPermission('currency.delete');
......@@ -188,7 +187,7 @@ public static function deleteCurrency(string $currency)
/**
* Return the default currency
*
* @return Currency
* @return Currency|null
* @throws QUI\Exception
*/
public static function getDefaultCurrency(): ?Currency
......@@ -200,7 +199,7 @@ public static function getDefaultCurrency(): ?Currency
self::$Default = self::getCurrency(
$Config->getValue('currency', 'defaultCurrency')
);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
QUI\System\Log::addWarning('Default currency is missing');
try {
......@@ -321,7 +320,7 @@ public static function getAllowedCurrencies(): array
foreach ($allowed as $currency) {
try {
$list[] = self::getCurrency($currency);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
}
......@@ -378,7 +377,7 @@ public static function getCurrency(Currency | string | array $currency): Currenc
if (is_string($currency)) {
$code = $currency;
} elseif (is_array($currency) && isset($currency['code'])) {
} elseif (isset($currency['code'])) {
$code = $currency['code'];
}
......@@ -415,10 +414,10 @@ public static function existCurrency(string $currency): bool
/**
* Return all currency entries
*
* @param Locale|boolean $Locale - optional, for translation
* @param Locale|null $Locale - optional, for translation
* @return array
*/
public static function getCurrencies($Locale = false): array
public static function getCurrencies(null | QUI\Locale $Locale = null): array
{
if (!$Locale) {
$Locale = QUI::getLocale();
......@@ -429,12 +428,12 @@ public static function getCurrencies($Locale = false): array
try {
return QUI\Cache\Manager::get($cacheNameLang);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
try {
$currencies = QUI\Cache\Manager::get($cacheName);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
$currencies = [];
$data = self::getData();
......@@ -448,7 +447,7 @@ public static function getCurrencies($Locale = false): array
foreach ($currencies as $currency) {
try {
$Currency = self::getCurrency($currency);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
continue;
}
......@@ -465,7 +464,7 @@ public static function getCurrencies($Locale = false): array
* @throws QUI\Database\Exception
* @throws QUI\Exception
*/
public static function updateCurrency($currency, $data)
public static function updateCurrency($currency, $data): void
{
QUI\Permissions\Permission::checkPermission('currency.edit');
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren