mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-22 18:20:31 -05:00
refactor: add literal separator to numbers
- This is for PHP7.4 + only - Adds an `_` as thousands separator in numbers
This commit is contained in:
@@ -15,15 +15,15 @@ namespace App\Helpers;
|
||||
|
||||
class StringHelper
|
||||
{
|
||||
const KIB = 1024;
|
||||
const KIB = 1_024;
|
||||
|
||||
const MIB = 1024 * 1024;
|
||||
const MIB = 1_024 * 1_024;
|
||||
|
||||
const GIB = 1024 * 1024 * 1024;
|
||||
const GIB = 1_024 * 1_024 * 1_024;
|
||||
|
||||
const TIB = 1024 * 1024 * 1024 * 1024;
|
||||
const TIB = 1_024 * 1_024 * 1_024 * 1_024;
|
||||
|
||||
const PIB = 1024 * 1024 * 1024 * 1024 * 1024;
|
||||
const PIB = 1_024 * 1_024 * 1_024 * 1_024 * 1_024;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -91,25 +91,25 @@ class StringHelper
|
||||
if ($seconds == 0) {
|
||||
return 'N/A';
|
||||
}
|
||||
while ($seconds >= 31536000) {
|
||||
while ($seconds >= 31_536_000) {
|
||||
$years++;
|
||||
$seconds -= 31536000;
|
||||
$seconds -= 31_536_000;
|
||||
}
|
||||
while ($seconds >= 2592000) {
|
||||
while ($seconds >= 2_592_000) {
|
||||
$months++;
|
||||
$seconds -= 2592000;
|
||||
$seconds -= 2_592_000;
|
||||
}
|
||||
while ($seconds >= 604800) {
|
||||
while ($seconds >= 604_800) {
|
||||
$weeks++;
|
||||
$seconds -= 604800;
|
||||
$seconds -= 604_800;
|
||||
}
|
||||
while ($seconds >= 86400) {
|
||||
while ($seconds >= 86_400) {
|
||||
$days++;
|
||||
$seconds -= 86400;
|
||||
$seconds -= 86_400;
|
||||
}
|
||||
while ($seconds >= 3600) {
|
||||
while ($seconds >= 3_600) {
|
||||
$hours++;
|
||||
$seconds -= 3600;
|
||||
$seconds -= 3_600;
|
||||
}
|
||||
while ($seconds >= 60) {
|
||||
$minutes++;
|
||||
@@ -145,25 +145,25 @@ class StringHelper
|
||||
if ($seconds == 0) {
|
||||
return 'N/A';
|
||||
}
|
||||
while ($seconds >= 31536000) {
|
||||
while ($seconds >= 31_536_000) {
|
||||
$years++;
|
||||
$seconds -= 31536000;
|
||||
$seconds -= 31_536_000;
|
||||
}
|
||||
while ($seconds >= 2592000) {
|
||||
while ($seconds >= 2_592_000) {
|
||||
$months++;
|
||||
$seconds -= 2592000;
|
||||
$seconds -= 2_592_000;
|
||||
}
|
||||
while ($seconds >= 604800) {
|
||||
while ($seconds >= 604_800) {
|
||||
$weeks++;
|
||||
$seconds -= 604800;
|
||||
$seconds -= 604_800;
|
||||
}
|
||||
while ($seconds >= 86400) {
|
||||
while ($seconds >= 86_400) {
|
||||
$days++;
|
||||
$seconds -= 86400;
|
||||
$seconds -= 86_400;
|
||||
}
|
||||
while ($seconds >= 3600) {
|
||||
while ($seconds >= 3_600) {
|
||||
$hours++;
|
||||
$seconds -= 3600;
|
||||
$seconds -= 3_600;
|
||||
}
|
||||
while ($seconds >= 60) {
|
||||
$minutes++;
|
||||
|
||||
Reference in New Issue
Block a user