Function prepareFilters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function prepareFilters(array $search): self
{
$dto = new self($search);
$dto->addToCriteria(new NotNullCriterion($dto->model()->getTable() . '.executed_at'));
if ($dto->getStatus()) {
- 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 toArray has a boolean flag argument $filters, which is a certain sign of a Single Responsibility Principle violation. Open
public function toArray($filters = false): array
- 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
Avoid using static access to class '\EscolaLms\Consultations\Models\ConsultationUserTerm' in method 'model'. Open
return ConsultationUserTerm::newModelInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$filters'. Open
public function toArray($filters = false): array
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused private methods such as 'addToCriteria'. Open
private function addToCriteria($value): void
{
$this->criteria[] = $value;
}
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST)
Open
private array $status;
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$dto->addToCriteria(new DateCriterion($dto->model()->getTable() . '.executed_at', $dto->getDateFrom(), '>='));
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$dto->addToCriteria(new WhereCriterion($dto->model()->getTable() . '.executed_at', $dto->getDateTimeFrom(), '>='));
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$dto->addToCriteria(new WhereNotInOrIsNullCriterion($dto->model()->getTable() . '.reminder_status', $dto->getReminderStatus()));
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$dto->addToCriteria(new WhereCriterion($dto->model()->getTable() . '.executed_at', $dto->getDateTimeTo(), '<='));
- Exclude checks