1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-10-27 20:32:28 +01:00

Replace magic numbers with constants (#754)

* Replace magic numbers with constants
This commit is contained in:
Lance Pioch 2017-11-12 18:16:54 -05:00 committed by Dane Everitt
parent 6043114f38
commit f94e4c15b0
3 changed files with 10 additions and 3 deletions

View File

@ -15,6 +15,8 @@ use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
class CleanServiceBackupFilesCommand extends Command
{
const BACKUP_THRESHOLD_MINUTES = 5;
/**
* @var \Carbon\Carbon
*/
@ -58,7 +60,7 @@ class CleanServiceBackupFilesCommand extends Command
collect($files)->each(function ($file) {
$lastModified = $this->carbon->timestamp($this->disk->lastModified($file));
if ($lastModified->diffInMinutes($this->carbon->now()) > 5) {
if ($lastModified->diffInMinutes($this->carbon->now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file);
$this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file]));
}

View File

@ -18,6 +18,9 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
{
use Searchable;
const THRESHOLD_PERCENTAGE_LOW = 75;
const THRESHOLD_PERCENTAGE_MEDIUM = 90;
/**
* {@inheritdoc}
*/
@ -56,7 +59,7 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
'value' => number_format($value),
'max' => number_format($maxUsage),
'percent' => $percent,
'css' => ($percent <= 75) ? 'green' : (($percent > 90) ? 'red' : 'yellow'),
'css' => ($percent <= self::THRESHOLD_PERCENTAGE_LOW) ? 'green' : (($percent > self::THRESHOLD_PERCENTAGE_MEDIUM) ? 'red' : 'yellow'),
],
];
})

View File

@ -16,6 +16,8 @@ use Pterodactyl\Exceptions\Service\Schedule\Task\TaskIntervalTooLongException;
class TaskCreationService
{
const MAX_INTERVAL_TIME_SECONDS = 900;
/**
* @var \Pterodactyl\Contracts\Repository\TaskRepositoryInterface
*/
@ -50,7 +52,7 @@ class TaskCreationService
$schedule = ($schedule instanceof Schedule) ? $schedule->id : $schedule;
$delay = $data['time_interval'] === 'm' ? $data['time_value'] * 60 : $data['time_value'];
if ($delay > 900) {
if ($delay > self::MAX_INTERVAL_TIME_SECONDS) {
throw new TaskIntervalTooLongException(trans('exceptions.tasks.chain_interval_too_long'));
}