Skip to content

Commit abbc189

Browse files
author
Kamshory, MT
committed
Fix codesmell
1 parent 4c8f4ba commit abbc189

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/Database/PicoDatabasePersistence.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class PicoDatabasePersistence // NOSONAR
8585
const COMMA_RETURN = ", \r\n";
8686
const INLINE_TRIM = " \r\n\t ";
8787
const ALWAYS_TRUE = "(1=1)";
88+
89+
const IS_NULL = " is null";
90+
const CLAUSE_AND = " and ";
8891

8992
/**
9093
* Database connection
@@ -929,7 +932,7 @@ private function getWhere($info, $queryBuilder)
929932
$value = $queryBuilder->escapeValue($value);
930933
if(strcasecmp($value, self::KEY_NULL) == 0)
931934
{
932-
$wheres[] = $columnName . " is null";
935+
$wheres[] = $columnName . self::IS_NULL;
933936
}
934937
else
935938
{
@@ -940,7 +943,7 @@ private function getWhere($info, $queryBuilder)
940943
{
941944
throw new NoPrimaryKeyDefinedException("No primary key defined");
942945
}
943-
return implode(" and ", $wheres);
946+
return implode(self::CLAUSE_AND, $wheres);
944947
}
945948

946949
/**
@@ -977,7 +980,7 @@ private function getWhereWithColumns($info, $queryBuilder)
977980
$escapedValue = $queryBuilder->escapeValue($value);
978981
if(strcasecmp($escapedValue, self::KEY_NULL) == 0)
979982
{
980-
$wheres[] = $columnName . " is null";
983+
$wheres[] = $columnName . self::IS_NULL;
981984
$columns[$columnName] = null;
982985
}
983986
else
@@ -992,7 +995,7 @@ private function getWhereWithColumns($info, $queryBuilder)
992995
}
993996

994997
$result->columns = $columns;
995-
$result->whereClause = implode(" and ", $wheres);
998+
$result->whereClause = implode(self::CLAUSE_AND, $wheres);
996999
return $result;
9971000
}
9981001

@@ -2150,14 +2153,14 @@ private function createWhereByPrimaryKeys($queryBuilder, $primaryKeys, $property
21502153
$columnValue = $propertyValues[$index];
21512154
if($columnValue === null)
21522155
{
2153-
$wheres[] = $columnName . " is null";
2156+
$wheres[] = $columnName . self::IS_NULL;
21542157
}
21552158
else
21562159
{
21572160
$wheres[] = $columnName . " = " . $queryBuilder->escapeValue($propertyValues[$index]);
21582161
}
21592162
}
2160-
$where = implode(" and ", $wheres);
2163+
$where = implode(self::CLAUSE_AND, $wheres);
21612164
if(!$this->isValidFilter($where))
21622165
{
21632166
throw new InvalidFilterException(self::MESSAGE_INVALID_FILTER);

src/Database/PicoPageData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function getResultAsArray()
303303
* @param mixed $data The data to convert. Can be a MagicObject, an array, an object, or a scalar value.
304304
* @return mixed The converted data as a plain PHP array, stdClass object, or scalar value.
305305
*/
306-
protected function magicObjectToArray($data)
306+
protected function magicObjectToArray($data) // NOSONAR
307307
{
308308
// Null or scalar
309309
if (is_null($data) || is_scalar($data)) {

0 commit comments

Comments
 (0)