From 01c5eceeb4166a7b28827505c4afd498b77d30b2 Mon Sep 17 00:00:00 2001 From: kj Date: Fri, 19 Jun 2026 14:52:25 -0300 Subject: [PATCH] refactor(model): Use match expression for PDO type detection --- src/Libs/Model.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Libs/Model.php b/src/Libs/Model.php index d6d8c8f..d9cfc96 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -157,17 +157,13 @@ class Model try { $prepared = $db->prepare($query); foreach (static::$dbQueryVariables as $key => $value) { - // Detectar el tipo de dato para elegir la constante de PDO - $type = PDO::PARAM_STR; // Por defecto string - if (is_int($value)) { - $type = PDO::PARAM_INT; - } - if (is_bool($value)) { - $type = PDO::PARAM_BOOL; - } - if (is_null($value)) { - $type = PDO::PARAM_NULL; - } + // Detect data type to choose the PDO constant + $type = match (gettype($value)) { + 'integer' => PDO::PARAM_INT, + 'boolean' => PDO::PARAM_BOOL, + 'NULL' => PDO::PARAM_NULL, + default => PDO::PARAM_STR, + }; $prepared->bindValue($key, $value, $type); }