YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Vtiger/models/Field.php

Summary

Maintainability
A
0 mins
Test Coverage
F
46%

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

        } else {
            $moduleName = parent::getModuleName();
        }

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

Reference to undeclared property \Settings_Vtiger_Field_Model->validator
Open

        return $this->validator ?? parent::getValidator();

Reference to undeclared property \Settings_Vtiger_Field_Model->module
Open

            $moduleName = $this->module->getParentName() . ':' . $this->module->getName();

Reference to undeclared property \Settings_Vtiger_Field_Model->isReadOnly (Did you mean \Settings_Vtiger_Field_Model->isReadOnly() or expr->readonly)
Open

        return $this->isReadOnly ?? false;

Reference to undeclared property \Settings_Vtiger_Field_Model->module
Open

        if (!empty($this->module) && method_exists($this->module, 'getParentName')) {

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Settings_Vtiger_Field_Model extends Vtiger_Field_Model

The class Settings_Vtiger_Field_Model is not named in CamelCase.
Open

class Settings_Vtiger_Field_Model extends Vtiger_Field_Model
{
    /**
     * Function to check if the field is named field of the module.
     *

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->isReadOnly ?? false;

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getModuleName()

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isNameField(): bool

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getFieldDataType()

Spaces must be used to indent lines; tabs are not allowed
Open

        return false;

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to check whether the current field is read-only.

Spaces must be used to indent lines; tabs are not allowed
Open

            $moduleName = $this->module->getParentName() . ':' . $this->module->getName();

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $moduleName = '';

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getValidator()

Spaces must be used to indent lines; tabs are not allowed
Open

            $moduleName = parent::getModuleName();

Spaces must be used to indent lines; tabs are not allowed
Open

        return $moduleName;

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->fieldDataType = 'icon';

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isReadOnly(): bool

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!isset($this->fieldDataType) && 62 === $this->uitype) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return parent::getFieldDataType();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to check if the field is named field of the module.

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->validator ?? parent::getValidator();

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!empty($this->module) && method_exists($this->module, 'getParentName')) {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Class name "Settings_Vtiger_Field_Model" is not in camel caps format
Open

class Settings_Vtiger_Field_Model extends Vtiger_Field_Model

There are no issues that match your filters.

Category
Status