YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using undefined variables such as '$map' which will lead to PHP notices.
Open

            self::$data[$type] = $map ?? [];

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Avoid using static access to class '\App\Utils' in method 'remove'.
Open

        \App\Utils::saveToFile(self::$types[$this->get('type')], $content);

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 '\App\Utils' in method 'putToFile'.
Open

        \App\Utils::saveToFile(self::$types[$this->get('type')], $content);

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 unused local variables such as '$map'.
Open

            self::$data[$type] = $map ?? [];

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Variable $map is undeclared
Open

            self::$data[$type] = $map ?? [];

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

class Settings_RecordAllocation_Module_Model extends Settings_Vtiger_Module_Model

The class Settings_RecordAllocation_Module_Model is not named in CamelCase.
Open

class Settings_RecordAllocation_Module_Model extends Settings_Vtiger_Module_Model
{
    private static $data = [];
    private static $types = [
        'owner' => 'app_data/module_record_allocation.php',

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

        $moduleName = $data['module'];

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

        unset($fileData[$moduleName]);

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

        $fileData[$moduleName][$userId] = $userData;

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

        $fileData = self::loadFile($type);

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

        return $fileData[$moduleName] ?? [];

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

            $file = self::$types[$type];

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

        self::$data = [];

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

        $userData = $data['ids'] ?? [];

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

    public function remove($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 static function getRecordAllocationByModule($type, $moduleName)

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

        'sharedOwner' => 'app_data/sharedOwner.php',

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

            self::$data[$type] = $map ?? [];

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 self::$data[$type];

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 (!isset(self::$data[$type])) {

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($fileData[$moduleName])) {

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

            require $file;

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

    }

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

            $fileData[$moduleName] = [];

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

    public static function resetDataVariable()

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

        $fileData = self::loadFile($this->get('type'));

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

        'owner' => 'app_data/module_record_allocation.php',

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

    public function save($data)

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

        \App\Utils::saveToFile(self::$types[$this->get('type')], $content);

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

    {

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

        \App\Utils::saveToFile(self::$types[$this->get('type')], $content);

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

    {

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

    private static $types = [

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

        $userId = $data['userid'];

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

        }

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

        $content = '$map=' . var_export($fileData, true) . ';';

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

        $fileData = self::loadFile($this->get('type'));

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

    private static $data = [];

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

    ];

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

        $this->putToFile($moduleName, $userId, $userData);

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

        $content = '$map=' . var_export($fileData, true) . ';';

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

    public function putToFile($moduleName, $userId, $userData)

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 static function loadFile($type)

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

        if (empty(self::$types[$type])) {

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

            return [];

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_RecordAllocation_Module_Model" is not in camel caps format
Open

class Settings_RecordAllocation_Module_Model extends Settings_Vtiger_Module_Model

There are no issues that match your filters.

Category
Status