Убрано дублирование классов. Helpers уехали из Core. Классы во внешних директориях переехали к остальным.

This commit is contained in:
2023-08-14 18:15:05 +03:00
parent 81a8161d32
commit 0d2b4aba63
114 changed files with 12919 additions and 13151 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace Helper;
/** All raw mathematics in one place. */
class Math
{
/**
* @param float|int $total
* @param int|null $number
* @return float
*/
public static function getPercentage($total, ?int $number): float
{
if (is_null($number)) {
return 0;
}
return $total > 0 ? round(($number * 100) / $total, 2) : 0;
}
public static function get100Percentage($total, ?int $number)
{
if (is_null($number)) {
return 0;
}
return min(self::getPercentage($total, $number), 100);
}
/** Number-20% and Number+20% */
public static function get20PercentRange($number): array
{
return [
'min' => $number * ((100 - 20) / 100),
'max' => $number * ((100 + 20) / 100),
];
}
public static function addPercent($num, $percent)
{
return $num + (($percent / 100) * $num);
}
}