Function buildRequireArrayQuery
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function buildRequireArrayQuery($subclause, Builder $query)
{
if ($subclause['operator'] == 'IN') {
$query->whereIn($subclause['to_value_column'], $subclause['value']);
} elseif ($subclause['operator'] == 'NOT IN') {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method buildSubclauseWithNull has a boolean flag argument $isNotNull, which is a certain sign of a Single Responsibility Principle violation. Open
private function buildSubclauseWithNull($subclause, Builder $query, $isNotNull = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
function(Builder $query) use ($subclause) {
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
return $this->buildSubclauseWithNull($subclause, $query, ($subclause['operator'] == 'NOT NULL' ? true : false));
- Exclude checks
The variable $require_array is not named in camelCase. Open
private function buildSubclauseQuery($query, $rule, $value, $condition)
{
/*
* Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
* into on one that we can use inside the SQL query
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $require_array is not named in camelCase. Open
private function buildSubclauseQuery($query, $rule, $value, $condition)
{
/*
* Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
* into on one that we can use inside the SQL query
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_sql_op is not named in camelCase. Open
private function buildSubclauseQuery($query, $rule, $value, $condition)
{
/*
* Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
* into on one that we can use inside the SQL query
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_sql_op is not named in camelCase. Open
private function buildSubclauseQuery($query, $rule, $value, $condition)
{
/*
* Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
* into on one that we can use inside the SQL query
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}