src/Model/Scope/Condition.php

Summary

Maintainability
F
3 days
Test Coverage

Function toQueryArguments has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function toQueryArguments(): array
    {
        $field = $this->field;
        $operator = $this->operator;
        $value = $this->value;
Severity: Minor
Found in src/Model/Scope/Condition.php - About 6 hrs to fix

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

File Condition.php has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data\Model\Scope;
Severity: Minor
Found in src/Model/Scope/Condition.php - About 4 hrs to fix

Function valueToWords has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    protected function valueToWords(Model $model, $value): string
    {
        if ($value === null) {
            return $this->operator
                ? 'empty'
Severity: Minor
Found in src/Model/Scope/Condition.php - About 3 hrs to fix

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

Function __construct has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($field, $operator = null, $value = null)
    {
        if ($field instanceof AbstractScope) {
            throw new Exception('Only Scope can contain another conditions');
        } elseif ($field instanceof Field) { // for BC
Severity: Minor
Found in src/Model/Scope/Condition.php - About 2 hrs to fix

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

Method toQueryArguments has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function toQueryArguments(): array
    {
        $field = $this->field;
        $operator = $this->operator;
        $value = $this->value;
Severity: Major
Found in src/Model/Scope/Condition.php - About 2 hrs to fix

Method valueToWords has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function valueToWords(Model $model, $value): string
    {
        if ($value === null) {
            return $this->operator
                ? 'empty'
Severity: Major
Found in src/Model/Scope/Condition.php - About 2 hrs to fix

Method __construct has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($field, $operator = null, $value = null)
    {
        if ($field instanceof AbstractScope) {
            throw new Exception('Only Scope can contain another conditions');
        } elseif ($field instanceof Field) { // for BC
Severity: Minor
Found in src/Model/Scope/Condition.php - About 1 hr to fix

Function fieldToWords has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fieldToWords(Model $model): string
    {
        $words = [];

        $field = $this->field;
Severity: Minor
Found in src/Model/Scope/Condition.php - About 1 hr to fix

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

Method fieldToWords has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function fieldToWords(Model $model): string
    {
        $words = [];

        $field = $this->field;
Severity: Minor
Found in src/Model/Scope/Condition.php - About 1 hr to fix

Function onChangeModel has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    #[\Override]
    protected function onChangeModel(): void
    {
        $model = $this->getModel();
        if ($model !== null) {
Severity: Minor
Found in src/Model/Scope/Condition.php - About 1 hr to fix

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

Avoid too many return statements within this method.
Open

            return 'object ' . print_r($value, true);
Severity: Major
Found in src/Model/Scope/Condition.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $valueStr . ($title !== null ? ' (\'' . $title . '\')' : '');
Severity: Major
Found in src/Model/Scope/Condition.php - About 30 mins to fix

There are no issues that match your filters.

Category
Status