From 1056e1db8bf8e4f5fca6aedc4e5b76a8449718f6 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Wed, 27 Oct 2021 19:09:09 +0200 Subject: [PATCH] let magic make this even better Right DataTypes, Removed unnessecary function --- app/Http/Controllers/HomeController.php | 34 ++++--------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index e2283412..fa8611d4 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -25,7 +25,7 @@ class HomeController extends Controller * * @return string */ - public function getTimeLeftBoxBackground($days) + public function getTimeLeftBoxBackground(float $days) { switch ($days) { @@ -49,12 +49,12 @@ class HomeController extends Controller /** * @description Get the Text for the Days-Left-Box in HomeView * - * @param string $days - * @param string $hours + * @param float $days + * @param float $hours * * @return string */ - public function getTimeLeftBoxText(string $days, string $hours) + public function getTimeLeftBoxText(float $days, float $hours) { if ($days < 1) { @@ -70,30 +70,6 @@ class HomeController extends Controller return strval(number_format($days, 0)); } - /** - * @description Return either "days" or "hours" to use on the front-end - * - * @param float $days - * - * @return string - */ - public function getTimeLeftUnit($days) - { - switch ($days) - { - case ($days < 1): - return "hours"; - break; - - case ($days > 1): - return "days"; - break; - - default: - return "days"; - } - } - /** Show the application dashboard. */ public function index(Request $request) { @@ -111,7 +87,7 @@ class HomeController extends Controller $bg = $this->getTimeLeftBoxBackground($days); $boxText = $this->getTimeLeftBoxText($days, $hours); - $unit = $this->getTimeLeftUnit($days, $hours); + $unit = $days < 1 ? 'hours' : 'days'; }