YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Media/models/Module.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\Vtiger_Field_Model' in method 'getFieldInstanceByName'.
Open

            $this->fields[$name] = \Vtiger_Field_Model::init($moduleName, $params, $name);

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

Saw an @param annotation for edit, but it was not found in the param list of function getFieldInstanceByName(string $name) : \Vtiger_Field_Model
Open

     * @param bool   $edit

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

class Settings_Media_Module_Model extends Settings_Vtiger_Module_Model

The class Settings_Media_Module_Model is not named in CamelCase.
Open

class Settings_Media_Module_Model extends Settings_Vtiger_Module_Model
{
    /** @var string Module name */
    public $name = 'Media';
    /** @var string Parent name */

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

     * @param string $name

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

    public function getFieldInstanceByName(string $name)

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

     * Gets field instance by name.

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

                    'label' => 'LBL_ICON',

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 (!isset($this->fields[$name])) {

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 $parent = 'Settings';

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 ('image' === $name) {

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

                $params = [

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

        }

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

    /** @var \Settings_Picklist_Field_Model[] Fields model */

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

    /** @var string Module name */

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

    public $name = 'Media';

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

        return $this->fields[$name];

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

                    'column' => $name,

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

            $this->fields[$name] = \Vtiger_Field_Model::init($moduleName, $params, $name);

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

    protected $fields = [];

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

     *

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

     * @param bool   $edit

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

     * @return \Vtiger_Field_Model

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

            $params = [];

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

                    'uitype' => 69,

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

            }

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

    /** @var string Parent name */

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

                    'typeofdata' => 'V~O'

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

                    'name' => $name,

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

            $moduleName = $this->getName(true);

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

class Settings_Media_Module_Model extends Settings_Vtiger_Module_Model

There are no issues that match your filters.

Category
Status