lib/Ajde/Crud.php

Summary

Maintainability
F
3 days
Test Coverage

File Crud.php has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class Ajde_Crud extends Ajde_Object_Standard
{
    protected $_model = null;
Severity: Minor
Found in lib/Ajde/Crud.php - About 6 hrs to fix

    Ajde_Crud has 47 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Ajde_Crud extends Ajde_Object_Standard
    {
        protected $_model = null;
        protected $_collection = null;
    
    
    Severity: Minor
    Found in lib/Ajde/Crud.php - About 6 hrs to fix

      Function export has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public function export($format = 'excel')
          {
              /* @var $exporter Ajde_Crud_Export_Interface */
      
              $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
      Severity: Minor
      Found in lib/Ajde/Crud.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

      The class Ajde_Crud has an overall complexity of 122 which is very high. The configured complexity threshold is 50.
      Open

      class Ajde_Crud extends Ajde_Object_Standard
      {
          protected $_model = null;
          protected $_collection = null;
      
      
      Severity: Minor
      Found in lib/Ajde/Crud.php by phpmd

      Method export has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function export($format = 'excel')
          {
              /* @var $exporter Ajde_Crud_Export_Interface */
      
              $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
      Severity: Major
      Found in lib/Ajde/Crud.php - About 2 hrs to fix

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

            public function getCollectionView($viewParams = [], $persist = 'auto')
            {
                if (!$this->getCollection()->hasView()) {
                    $viewSession = new Ajde_Session('AC.Crud.View');
                    $sessionName = $this->getSessionName();
        Severity: Minor
        Found in lib/Ajde/Crud.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

        Function createField has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function createField($fieldOptions)
            {
                if (!isset($fieldOptions['type'])) {
                    $fieldOptions['type'] = 'text';
                }
        Severity: Minor
        Found in lib/Ajde/Crud.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

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

            public function getItem()
            {
                if ($this->isNew()) {
                    $this->fireCrudLoadedOnModel($this->getModel());
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.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

        Function getField has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getField($fieldName, $strict = true)
            {
                if (!isset($this->_fields)) {
                    $this->getFields();
                }
        Severity: Minor
        Found in lib/Ajde/Crud.php - About 25 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 export() has an NPath complexity of 364. The configured NPath complexity threshold is 200.
        Open

            public function export($format = 'excel')
            {
                /* @var $exporter Ajde_Crud_Export_Interface */
        
                $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
        Severity: Minor
        Found in lib/Ajde/Crud.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 export() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10.
        Open

            public function export($format = 'excel')
            {
                /* @var $exporter Ajde_Crud_Export_Interface */
        
                $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CyclomaticComplexity

        Since: 0.1

        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

        Example

        // Cyclomatic Complexity = 11
        class Foo {
        1   public function example() {
        2       if ($a == $b) {
        3           if ($a1 == $b1) {
                        fiddle();
        4           } elseif ($a2 == $b2) {
                        fiddle();
                    } else {
                        fiddle();
                    }
        5       } elseif ($c == $d) {
        6           while ($c == $d) {
                        fiddle();
                    }
        7        } elseif ($e == $f) {
        8           for ($n = 0; $n < $h; $n++) {
                        fiddle();
                    }
                } else {
                    switch ($z) {
        9               case 1:
                            fiddle();
                            break;
        10              case 2:
                            fiddle();
                            break;
        11              case 3:
                            fiddle();
                            break;
                        default:
                            fiddle();
                            break;
                    }
                }
            }
        }

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

        The class Ajde_Crud has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        Missing class import via use statement (line '47', column '54').
        Open

                $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/crud:'.$this->getOperation()));
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '569', column '33').
        Open

                        $crudView = new Ajde_Collection_View($sessionName, $this->getOption('list.view', []));
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Remove error control operator '@' on line 77.
        Open

            public function export($format = 'excel')
            {
                /* @var $exporter Ajde_Crud_Export_Interface */
        
                $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ErrorControlOperator

        Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

        Example

        function foo($filePath) {
            $file = @fopen($filPath); // hides exceptions
            $key = @$array[$notExistingKey]; // assigns null to $key
        }

        Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

        Missing class import via use statement (line '600', column '25').
        Open

                $template = new Ajde_Template(MODULE_DIR.'_core/', 'crud/'.$this->getOperation());
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

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

            public function getField($fieldName, $strict = true)
        Severity: Minor
        Found in lib/Ajde/Crud.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

        Missing class import via use statement (line '603', column '29').
        Open

                    $template = new Ajde_Template(MODULE_DIR.'_core/', 'crud/'.$this->getAction());
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

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

            public function getOption($name, $default = false)
        Severity: Minor
        Found in lib/Ajde/Crud.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

        Missing class import via use statement (line '563', column '32').
        Open

                    $viewSession = new Ajde_Session('AC.Crud.View');
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '494', column '27').
        Open

                        throw new Ajde_Exception($fieldName.' is not a field in '.(string) $this->getModel()->getTable());
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '608', column '29').
        Open

                    $template = new Ajde_Template($base, $action);
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Remove error control operator '@' on line 107.
        Open

            public function export($format = 'excel')
            {
                /* @var $exporter Ajde_Crud_Export_Interface */
        
                $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ErrorControlOperator

        Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

        Example

        function foo($filePath) {
            $file = @fopen($filPath); // hides exceptions
            $key = @$array[$notExistingKey]; // assigns null to $key
        }

        Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

        The method createField uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                        } else {
                            $field->setValue(false);
                        }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid using static access to class 'Ajde_Core_ExternalLibs' in method 'createField'.
        Open

                $fieldClass = Ajde_Core_ExternalLibs::getClassname('Ajde_Crud_Field_'.ucfirst($fieldOptions['type']));
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        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 using static access to class 'Ajde_Template' in method '_hasCustomTemplate'.
        Open

                return Ajde_Template::exist($base, $action) !== false;
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        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 using static access to class 'Ajde_Controller' in method 'output'.
        Open

                $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/crud:'.$this->getOperation()));
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        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

        The method getItem uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        if (!$model->getAutoloadParents()) {
                            $model->loadParents();
                        }
                    }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid using static access to class 'Ajde_Exception_Handler' in method '__toString'.
        Open

                    $output = Ajde_Exception_Handler::handler($e);
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        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

        The method getSessionName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    return (string) $this->getModel()->getTable();
                }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    $modelName = $this->toCamelCase($model, true).'Model';
                    $this->_model = new $modelName();
                }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method export uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                        } else {
                            if ($this->getField($fieldName) instanceof Ajde_Crud_Field_Sort) {
                                $row[] = $value;
                                // Display function
                                //                } elseif ($field->hasFunction() && $field->getFunction()) {
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method getOptions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    return parent::getOptions();
                }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method getField uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    if ($strict === true) {
                        // TODO:
                        throw new Ajde_Exception($fieldName.' is not a field in '.(string) $this->getModel()->getTable());
                    } else {
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid assigning values to variables in if clauses and the like (line '73', column '37').
        Open

            public function export($format = 'excel')
            {
                /* @var $exporter Ajde_Crud_Export_Interface */
        
                $exporterClass = 'Ajde_Crud_Export_'.ucfirst($format);
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

        Avoid using static access to class 'Ajde_Http_Response' in method 'getItem'.
        Open

                        Ajde_Http_Response::redirectNotFound();
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        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

        The method export uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $field = $this->getField($fieldName);
                        $headers[] = $field->getLabel();
                    }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method getCollectionView uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $crudView = new Ajde_Collection_View($sessionName, $this->getOption('list.view', []));
                        $crudView->setColumns($this->getOption('list.show', $this->getFieldNames()));
                    }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method getOption uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        return $default;
                    }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid using static access to class 'Ajde_Event' in method 'fireCrudLoadedOnModel'.
        Open

                Ajde_Event::trigger($model, 'afterCrudLoaded');
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        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

        The method getField uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        return false;
                    }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        The method export uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                            } else {
                                $row[] = strip_tags($value);
                            }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid using count() function in for loops.
        Open

                            for ($i = 0; $i < ($maxJsonFields - count($jsonFields)); $i++) {
                                $row[] = '';
                            }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CountInLoopExpression

        Since: 2.7.0

        Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

        Example

        class Foo {
        
          public function bar()
          {
            $array = array();
        
            for ($i = 0; count($array); $i++) {
              // ...
            }
          }
        }

        Source https://phpmd.org/rules/design.html#countinloopexpression

        TODO found
        Open

                // TODO: changed getItem to getModel, any side effects?
        Severity: Minor
        Found in lib/Ajde/Crud.php by fixme

        TODO found
        Open

                // TODO: this should be done with JOIN
        Severity: Minor
        Found in lib/Ajde/Crud.php by fixme

        TODO found
        Open

                        // TODO:
        Severity: Minor
        Found in lib/Ajde/Crud.php by fixme

        The property $_fields is not named in camelCase.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $_operation is not named in camelCase.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $_model is not named in camelCase.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $_collection is not named in camelCase.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        Avoid variables with short names like $id. Configured minimum length is 3.
        Open

            public function loadItem($id = null)
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        Avoid variables with short names like $wc. Configured minimum length is 3.
        Open

                $wc = &$options;
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        The property $_templateData is not named in camelCase.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The class Ajde_Crud is not named in CamelCase.
        Open

        class Ajde_Crud extends Ajde_Object_Standard
        {
            protected $_model = null;
            protected $_collection = null;
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCaseClassName

        Since: 0.2

        It is considered best practice to use the CamelCase notation to name classes.

        Example

        class class_name {
        }

        Source

        The method _getCustomTemplateAction is not named in camelCase.
        Open

            private function _getCustomTemplateAction()
            {
                return 'crud/'.(string) $this->getModel()->getTable().DIRECTORY_SEPARATOR.$this->getAction();
            }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCaseMethodName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name methods.

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method _getCustomTemplateBase is not named in camelCase.
        Open

            private function _getCustomTemplateBase()
            {
                return MODULE_DIR.$this->getCustomTemplateModule().DIRECTORY_SEPARATOR;
            }
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCaseMethodName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name methods.

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method _hasCustomTemplate is not named in camelCase.
        Open

            private function _hasCustomTemplate()
            {
                $base = $this->_getCustomTemplateBase();
                $action = $this->_getCustomTemplateAction();
        
        
        Severity: Minor
        Found in lib/Ajde/Crud.php by phpmd

        CamelCaseMethodName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name methods.

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        There are no issues that match your filters.

        Category
        Status