refactor: add literal separator to numbers

- This is for PHP7.4 + only
- Adds an `_` as thousands separator in numbers
This commit is contained in:
HDVinnie
2020-04-14 20:25:07 -04:00
parent bb9002bc48
commit 46aa876c06
16 changed files with 63 additions and 63 deletions
+25 -25
View File
@@ -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++;