Skip to content

Commit

Permalink
fixed number utility for low ps version
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Oct 9, 2024
1 parent 60e656c commit dbcf634
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Utility/NumberUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use PrestaShop\Decimal\DecimalNumber;
use PrestaShop\Decimal\Exception\DivisionByZeroException;
use PrestaShop\Decimal\Number;
use PrestaShop\Decimal\Operation\Rounding;

if (!defined('_PS_VERSION_')) {
Expand Down Expand Up @@ -228,15 +229,18 @@ public static function plus(float $a, float $b): float
}

/**
* Creates a Number or DecimalNumber instance from a float.
* Creates a Number or DecimalNumber instance based on the current environment.
*
* @param float $number
*
* @return DecimalNumber
* @return DecimalNumber|Number
*/
private static function getNumber(float $number): DecimalNumber
private static function getNumber(float $number)
{
// Assuming DecimalNumber is the preferred class based on the use case.
return new DecimalNumber((string) $number);
if (is_subclass_of(Number::class, DecimalNumber::class)) {
return new DecimalNumber((string) $number);
}

return new Number((string) $number);
}
}
Empty file modified views/css/admin/logs/index.php
100755 → 100644
Empty file.
Empty file modified views/css/admin/logs/log.css
100755 → 100644
Empty file.
Empty file modified views/js/admin/logs/index.php
100755 → 100644
Empty file.
Empty file modified views/js/admin/logs/log.js
100755 → 100644
Empty file.
Empty file modified views/templates/admin/logs/index.php
100755 → 100644
Empty file.
Empty file modified views/templates/admin/logs/log_modal.tpl
100755 → 100644
Empty file.
Empty file modified views/templates/admin/logs/severity_level_column.tpl
100755 → 100644
Empty file.
Empty file modified views/templates/admin/logs/severity_levels.tpl
100755 → 100644
Empty file.

0 comments on commit dbcf634

Please sign in to comment.