SergioMadness/query-builder

View on GitHub
src/abstraction/SelectBuilder.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method generate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function generate()
    {
        $result = '';

        $table  = $this->buildTable();
Severity: Minor
Found in src/abstraction/SelectBuilder.php - About 1 hr to fix

    Function generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generate()
        {
            $result = '';
    
            $table  = $this->buildTable();
    Severity: Minor
    Found in src/abstraction/SelectBuilder.php - About 45 mins 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

    The method generate() has an NPath complexity of 256. The configured NPath complexity threshold is 200.
    Open

        public function generate()
        {
            $result = '';
    
            $table  = $this->buildTable();
    Severity: Minor
    Found in src/abstraction/SelectBuilder.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method forUpdate has a boolean flag argument $flag, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function forUpdate($flag = true)
    Severity: Minor
    Found in src/abstraction/SelectBuilder.php by phpmd

    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 abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildTable();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildLimit();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildSelectFields();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildUnion();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildGroup();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildHaving();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildWhere();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildJoin();

    The abstract declaration must precede the visibility declaration
    Open

        protected abstract function buildOrder();

    Expected 1 newline at end of file; 0 found
    Open

    }

    There are no issues that match your filters.

    Category
    Status