From daa323684bae6e75e1dea1a7030ce1a3186d990f Mon Sep 17 00:00:00 2001 From: vc-dhavaljoshi Date: Tue, 4 Jun 2024 18:58:47 +0530 Subject: [PATCH] #48 resolve issue getTableSize(): Return value must be of type string --- src/Constants/Constant.php | 2 ++ src/Traits/DBConnection.php | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Constants/Constant.php b/src/Constants/Constant.php index 2a70686..5b85d19 100644 --- a/src/Constants/Constant.php +++ b/src/Constants/Constant.php @@ -110,4 +110,6 @@ class Constant public const ACTION = 'action'; public const STATUS = 'status'; + + public const DEFAULT_SIZE = '0.00'; } diff --git a/src/Traits/DBConnection.php b/src/Traits/DBConnection.php index f8c1c15..e452d00 100644 --- a/src/Traits/DBConnection.php +++ b/src/Traits/DBConnection.php @@ -103,14 +103,15 @@ public function getTableSize(string $tableName): string ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC'; $result = DB::select($query); + if ($result) { - return $result[0]->size; + return $result[0]->size ?? Constant::DEFAULT_SIZE; } } catch (Exception $exception) { Log::error($exception->getMessage()); } - return Constant::NULL; + return Constant::DEFAULT_SIZE; } /**