From 79bcea83e0aacfc529f84797192d95296eeab3f1 Mon Sep 17 00:00:00 2001 From: arthurpar06 Date: Tue, 9 Jul 2024 21:19:27 +0000 Subject: [PATCH] Apply fixes from StyleCI --- .../2024_07_09_210356_update_db_charset.php | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/app/Database/migrations/2024_07_09_210356_update_db_charset.php b/app/Database/migrations/2024_07_09_210356_update_db_charset.php index 1de70443d..c93e14122 100644 --- a/app/Database/migrations/2024_07_09_210356_update_db_charset.php +++ b/app/Database/migrations/2024_07_09_210356_update_db_charset.php @@ -1,11 +1,8 @@ $column->Field, - 'type' => $type, + 'field' => $column->Field, + 'type' => $type, 'type_brackets' => $typeBrackets, - 'type_end' => $typeEnd, - 'null' => strtolower($column->Null) == 'yes', - 'default' => $column->Default, - 'charset' => is_string($column->Collation) && ($pos = strpos($column->Collation, '_')) !== false ? substr($column->Collation, 0, $pos) : null, - 'collation' => $column->Collation + 'type_end' => $typeEnd, + 'null' => strtolower($column->Null) == 'yes', + 'default' => $column->Default, + 'charset' => is_string($column->Collation) && ($pos = strpos($column->Collation, '_')) !== false ? substr($column->Collation, 0, $pos) : null, + 'collation' => $column->Collation, ]; } @@ -160,12 +157,12 @@ protected function isStringTypeWithLength($column) * lengths of those columns that have them to be the newLength provided, when the shouldUpdateLength callback passed * returns true. * - * @param string $table - * @param string $charset - * @param string $collation - * @param int|null $newLength - * @param Closure|null $shouldUpdateLength - * @param string|null $connection + * @param string $table + * @param string $charset + * @param string $collation + * @param int|null $newLength + * @param Closure|null $shouldUpdateLength + * @param string|null $connection */ protected function updateColumnsInTable($table, $charset, $collation, $newLength = null, Closure $shouldUpdateLength = null, $connection = null) { @@ -175,20 +172,20 @@ protected function updateColumnsInTable($table, $charset, $collation, $newLength $column = $this->extractInformationFromColumn($column); if ($this->isStringType($column)) { - $sql = "CHANGE `%field%` `%field%` %type%%brackets% CHARACTER SET %charset% COLLATE %collation% %null% %default%"; + $sql = 'CHANGE `%field%` `%field%` %type%%brackets% CHARACTER SET %charset% COLLATE %collation% %null% %default%'; $search = ['%field%', '%type%', '%brackets%', '%charset%', '%collation%', '%null%', '%default%']; $replace = [ $column['field'], $column['type'], - $column['type_brackets'] ? '(' . $column['type_brackets'] . ')' : '', + $column['type_brackets'] ? '('.$column['type_brackets'].')' : '', $charset, $collation, $column['null'] ? 'NULL' : 'NOT NULL', - is_null($column['default']) ? ($column['null'] ? 'DEFAULT NULL' : '') : 'DEFAULT \'' . $column['default'] . '\'' + is_null($column['default']) ? ($column['null'] ? 'DEFAULT NULL' : '') : 'DEFAULT \''.$column['default'].'\'', ]; if ($this->isStringTypeWithLength($column) && $shouldUpdateLength($column) && is_int($newLength) && $newLength > 0) { - $replace[2] = '(' . $newLength . ')'; + $replace[2] = '('.$newLength.')'; } $columnsToChange[] = trim(str_replace($search, $replace, $sql)); @@ -196,7 +193,7 @@ protected function updateColumnsInTable($table, $charset, $collation, $newLength } if (count($columnsToChange) > 0) { - $query = "ALTER TABLE `{$table}` " . implode(', ', $columnsToChange); + $query = "ALTER TABLE `{$table}` ".implode(', ', $columnsToChange); $this->getDatabaseConnection($connection)->update($query); } @@ -212,7 +209,7 @@ protected function updateColumnsInTable($table, $charset, $collation, $newLength */ protected function getColumnsFromTable($table, $connection = null) { - return $this->getDatabaseConnection($connection)->select('SHOW FULL COLUMNS FROM ' . $table); + return $this->getDatabaseConnection($connection)->select('SHOW FULL COLUMNS FROM '.$table); } /**