lib/Ajde/Crud/Field/Icon.php

Summary

Maintainability
B
5 hrs
Test Coverage

Method bootstrap2 has 142 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function bootstrap2()
    {
        return $this->convertBootstrapIcons([
            'icon-glass',
            'icon-music',
Severity: Major
Found in lib/Ajde/Crud/Field/Icon.php - About 5 hrs to fix

    The method bootstrap2() has 145 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        private function bootstrap2()
        {
            return $this->convertBootstrapIcons([
                'icon-glass',
                'icon-music',
    Severity: Minor
    Found in lib/Ajde/Crud/Field/Icon.php by phpmd

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

            } else {
                return $this->iconPackage($this->defaultPackage);
            }
    Severity: Minor
    Found in lib/Ajde/Crud/Field/Icon.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 class Ajde_Crud_Field_Icon is not named in CamelCase.
    Open

    class Ajde_Crud_Field_Icon extends Ajde_Crud_Field
    {
        private $defaultPackage = 'bootstrap-2-default';
    
        public function getIconPackage()
    Severity: Minor
    Found in lib/Ajde/Crud/Field/Icon.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 _getHtmlAttributes is not named in camelCase.
    Open

        protected function _getHtmlAttributes()
        {
            $attributes = [];
            $attributes['type'] = 'hidden';
            $attributes['value'] = $this->getValue();
    Severity: Minor
    Found in lib/Ajde/Crud/Field/Icon.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