YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

Function enableOrDisableValuesForRole has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function enableOrDisableValuesForRole($picklistFieldName, $valuesToEnables, $valuesToDisable, $roleIdList)
    {
        $db = App\Db::getInstance();
        $picklistId = (new App\Db\Query())->select(['picklistid'])->from('vtiger_picklist')
            ->where(['name' => $picklistFieldName])->scalar();
Severity: Minor
Found in modules/Settings/Picklist/models/Module.php - About 3 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

Method enableOrDisableValuesForRole has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function enableOrDisableValuesForRole($picklistFieldName, $valuesToEnables, $valuesToDisable, $roleIdList)
    {
        $db = App\Db::getInstance();
        $picklistId = (new App\Db\Query())->select(['picklistid'])->from('vtiger_picklist')
            ->where(['name' => $picklistFieldName])->scalar();
Severity: Minor
Found in modules/Settings/Picklist/models/Module.php - About 1 hr to fix

    The method enableOrDisableValuesForRole() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
    Open

        public function enableOrDisableValuesForRole($picklistFieldName, $valuesToEnables, $valuesToDisable, $roleIdList)
        {
            $db = App\Db::getInstance();
            $picklistId = (new App\Db\Query())->select(['picklistid'])->from('vtiger_picklist')
                ->where(['name' => $picklistFieldName])->scalar();

    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

    Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
    Open

        public function enableOrDisableValuesForRole($picklistFieldName, $valuesToEnables, $valuesToDisable, $roleIdList)

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

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

        public function getFieldsByType($type, bool $active = false): array

    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 '81', column '22').
    Open

            $dataReader = (new App\Db\Query())->select(['picklist_valueid', $picklistFieldName, $primaryKey])

    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 '77', column '22').
    Open

            $picklistId = (new App\Db\Query())->select(['picklistid'])->from('vtiger_picklist')

    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 '135', column '21').
    Open

            $expression = new \yii\db\Expression($set);

    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 '166', column '22').
    Open

            $dataReader = (new App\Db\Query())->select(['tabid', 'fieldname'])

    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

    Avoid using static access to class '\App\Fields\Picklist' in method 'enableOrDisableValuesForRole'.
    Open

                ->from(\App\Fields\Picklist::getPickListTableName($picklistFieldName))

    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\Purifier' in method 'enableOrDisableValuesForRole'.
    Open

                            $pickListValueId = $pickListValueDetails[App\Purifier::encodeHtml($picklistValue)];

    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 'Settings_Picklist_Field_Model' in method 'getFieldsByType'.
    Open

                    $field = Settings_Picklist_Field_Model::getInstanceFromFieldObject($fieldModel);

    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 enableOrDisableValuesForRole uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                        } else {
                            $pickListValueId = $pickListValueDetails[$picklistValue];
                        }

    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 '\App\Db' in method 'updateSequence'.
    Open

            $db = \App\Db::getInstance();

    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\Fields\Picklist' in method 'updateSequence'.
    Open

            $db->createCommand()->update(\App\Fields\Picklist::getPickListTableName($pickListFieldName), ['sortorderid' => $expression])->execute();

    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\Module' in method 'listModuleInterdependentPickList'.
    Open

                $moduleName = \App\Module::getModuleName($row['tabid']);

    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 enableOrDisableValuesForRole uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                        } else {
                            $pickListValueId = $pickListValueDetails[$picklistValue];
                        }

    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 '\Vtiger_Module_Model' in method 'listModuleInterdependentPickList'.
    Open

                $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);

    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\Db' in method 'enableOrDisableValuesForRole'.
    Open

            $db = App\Db::getInstance();

    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\Purifier' in method 'enableOrDisableValuesForRole'.
    Open

                $pickListValueDetails[App\Purifier::decodeHtml($row[$primaryKey])] = $row['picklist_valueid'];

    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\Fields\Picklist' in method 'enableOrDisableValuesForRole'.
    Open

            $primaryKey = App\Fields\Picklist::getPickListId($picklistFieldName);

    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\Fields\Picklist' in method 'updateSequence'.
    Open

            $primaryKey = App\Fields\Picklist::getPickListId($pickListFieldName);

    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 '\Vtiger_Module_Model' in method 'setSourceModule'.
    Open

            $this->sourceModule = \Vtiger_Module_Model::getInstance($sourceModule);

    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\Purifier' in method 'enableOrDisableValuesForRole'.
    Open

                            $pickListValueId = $pickListValueDetails[App\Purifier::encodeHtml($picklistValue)];

    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\Language' in method 'listModuleInterdependentPickList'.
    Open

                    $interdependent[$row['fieldname']][] = \App\Language::translate($moduleName, $moduleName);

    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

    Define a constant instead of duplicating this literal "roleid" 3 times.
    Open

                        $deleteValueList[] = ['roleid' => $roleId, 'picklistvalueid' => $pickListValueId];

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "fieldname" 4 times.
    Open

            $dataReader = (new App\Db\Query())->select(['tabid', 'fieldname'])

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "picklistvalueid" 3 times.
    Open

                        $deleteValueList[] = ['roleid' => $roleId, 'picklistvalueid' => $pickListValueId];

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Call to undeclared method \App\Db::quoteValue
    Open

                $set .= " WHEN {$db->quoteColumnName($primaryKey)} = {$db->quoteValue($values)} THEN {$db->quoteValue($sequence)}";

    Call to undeclared method \App\Db\Query::select
    Open

            $dataReader = (new App\Db\Query())->select(['picklist_valueid', $picklistFieldName, $primaryKey])

    Call to undeclared method \App\Db::createCommand
    Open

                $db->createCommand()->batchInsert('vtiger_role2picklist', ['roleid', 'picklistvalueid', 'picklistid'], $insertValueList)->execute();

    Call to undeclared method \App\Db::createCommand
    Open

                    $db->createCommand()->delete('vtiger_role2picklist', $deleteValueList)->execute();

    Call to undeclared method \App\Db::quoteColumnName
    Open

                $set .= " WHEN {$db->quoteColumnName($primaryKey)} = {$db->quoteValue($values)} THEN {$db->quoteValue($sequence)}";

    Call to method __construct from undeclared class \yii\db\Expression
    Open

            $expression = new \yii\db\Expression($set);

    Call to undeclared method \App\Db::createCommand
    Open

            $db->createCommand()->update(\App\Fields\Picklist::getPickListTableName($pickListFieldName), ['sortorderid' => $expression])->execute();

    Call to undeclared method \App\Db\Query::select
    Open

            $picklistId = (new App\Db\Query())->select(['picklistid'])->from('vtiger_picklist')

    Call to undeclared method \App\Db\Query::select
    Open

            $dataReader = (new App\Db\Query())->select(['tabid', 'fieldname'])

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

    class Settings_Picklist_Module_Model extends Settings_Vtiger_Module_Model

    The class Settings_Picklist_Module_Model is not named in CamelCase.
    Open

    class Settings_Picklist_Module_Model extends Settings_Vtiger_Module_Model
    {
        /** @var string Module name */
        public $name = 'Picklist';
        /** @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

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

            $db = \App\Db::getInstance();

    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 $db. Configured minimum length is 3.
    Open

            $db = App\Db::getInstance();

    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

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

            return $this->fields;

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

                            $pickListValueId = $pickListValueDetails[$picklistValue];

    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

            $objectProperties = get_object_vars($moduleObj);

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

            $interdependent = [];

    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

        public $sourceModule;

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

         * Set source 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

                $deleteValueList = [];

    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

        {

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

         * list of modules in which they appear picklist 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

                ->createCommand()->query();

    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

            $picklistId = (new App\Db\Query())->select(['picklistid'])->from('vtiger_picklist')

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

                $insertValueList = [];

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

                ->from('vtiger_field')

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

                    $interdependent[$row['fieldname']][] = \App\Language::translate($moduleName, $moduleName);

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

        /** @var \Vtiger_Module_Model Source module model */

    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

                ->createCommand()->query();

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

                        $insertValueList[] = [$roleId, $pickListValueId, $picklistId];

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

        }

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

            foreach ($picklistValues as $values => $sequence) {

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

         * @return self instance

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

            while ($row = $dataReader->read()) {

    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

         * @return $this

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

        public function getFieldsByType($type, bool $active = false): array

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

                    $this->fields[$fieldName] = $field;

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

         * @param string[] $roleIdList

    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

            $set = ' CASE ';

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

            foreach ($objectProperties as $properName => $propertyValue) {

    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 listModuleInterdependentPickList(array $pickListFields): array

    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

                ->from(\App\Fields\Picklist::getPickListTableName($picklistFieldName))

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

                            $pickListValueId = $pickListValueDetails[App\Purifier::encodeHtml($picklistValue)];

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

                }

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

            $expression = new \yii\db\Expression($set);

    Line exceeds 120 characters; contains 144 characters
    Open

            $db->createCommand()->update(\App\Fields\Picklist::getPickListTableName($pickListFieldName), ['sortorderid' => $expression])->execute();

    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

                ->where(['fieldname' => $pickListFields])

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

            $this->sourceModule = \Vtiger_Module_Model::getInstance($sourceModule);

    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 string   $picklistFieldName

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

            $dataReader->close();

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

                foreach ($roleIdList as $roleId) {

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

                if ($deleteValueList) {

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

            $primaryKey = App\Fields\Picklist::getPickListId($pickListFieldName);

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

            }

    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

         * @param string[] $valuesToDisable

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

         * @return void

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

            if ($pickListValueDetails && $pickListValueList) {

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

                        if (empty($pickListValueDetails[$picklistValue])) {

    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

                    foreach ($valuesToDisable as $picklistValue) {

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

                        if (empty($pickListValueDetails[$picklistValue])) {

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

         * @param string $sourceModule

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

            $pickListValueList = array_merge($valuesToEnables, $valuesToDisable);

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

                ->where([$primaryKey => $pickListValueList])

    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 string $pickListFieldName

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

        {

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

            $db->createCommand()->update(\App\Fields\Picklist::getPickListTableName($pickListFieldName), ['sortorderid' => $expression])->execute();

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

         * Function to get the instance of Vtiger Module Model from a given vtlib\Module object.

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

        public static function getInstanceFromModuleObject(vtlib\Module $moduleObj): self

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

                $moduleModel->{$properName} = $propertyValue;

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

        public $name = 'Picklist';

    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

         *

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

                    array_unshift($deleteValueList, 'or');

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

                $set .= " WHEN {$db->quoteColumnName($primaryKey)} = {$db->quoteValue($values)} THEN {$db->quoteValue($sequence)}";

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

         * @param vtlib\Module $moduleObj

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

            return $moduleModel;

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

                $moduleModel = \Vtiger_Module_Model::getInstance($moduleName);

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

                if ($moduleModel->isActive() && $moduleModel->getFieldByName($row['fieldname'])->isActiveField()) {

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

                $fieldModels = $this->sourceModule->getFieldsByType($type, $active);

    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

        }

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

            $dataReader = (new App\Db\Query())->select(['picklist_valueid', $picklistFieldName, $primaryKey])

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

                    foreach ($valuesToEnables as $picklistValue) {

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

                        $deleteValueList[] = ['roleid' => $roleId, 'picklistvalueid' => $pickListValueId];

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

                    $db->createCommand()->delete('vtiger_role2picklist', $deleteValueList)->execute();

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

            $moduleModel = new self();

    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

            $primaryKey = App\Fields\Picklist::getPickListId($picklistFieldName);

    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 updateSequence($pickListFieldName, $picklistValues)

    Line exceeds 120 characters; contains 127 characters
    Open

                $set .= " WHEN {$db->quoteColumnName($primaryKey)} = {$db->quoteValue($values)} THEN {$db->quoteValue($sequence)}";

    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 string $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 function enableOrDisableValuesForRole($picklistFieldName, $valuesToEnables, $valuesToDisable, $roleIdList)

    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 array $pickListFields

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

                $moduleName = \App\Module::getModuleName($row['tabid']);

    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 setSourceModule(string $sourceModule)

    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

            if (!$this->fields) {

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

        public function getFieldByName($name)

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

         * @param string[] $valuesToEnables

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

            $db = App\Db::getInstance();

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

                ->where(['name' => $picklistFieldName])->scalar();

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

            while ($row = $dataReader->read()) {

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

                            $pickListValueId = $pickListValueDetails[App\Purifier::encodeHtml($picklistValue)];

    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

                $db->createCommand()->batchInsert('vtiger_role2picklist', ['roleid', 'picklistvalueid', 'picklistid'], $insertValueList)->execute();

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

         * @return array

    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 $interdependent;

    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

         * Enable or disable values for role.

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

                $pickListValueDetails[App\Purifier::decodeHtml($row[$primaryKey])] = $row['picklist_valueid'];

    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 update sequence number.

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

            $db = \App\Db::getInstance();

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

            $set .= ' END';

    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

        {

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

            return $this;

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

                foreach ($fieldModels as $fieldName => $fieldModel) {

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

                    $field = Settings_Picklist_Field_Model::getInstanceFromFieldObject($fieldModel);

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

         * Get fields instance by name.

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

            return $this->getFieldsByType(['picklist', 'multipicklist'], true)[$name] ?? null;

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

            $pickListValueDetails = [];

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

                        $deleteValueList[] = ['roleid' => $roleId, 'picklistvalueid' => $pickListValueId];

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

                            $pickListValueId = $pickListValueDetails[$picklistValue];

    Line exceeds 120 characters; contains 144 characters
    Open

                $db->createCommand()->batchInsert('vtiger_role2picklist', ['roleid', 'picklistvalueid', 'picklistid'], $insertValueList)->execute();

    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 array  $picklistValues

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

         */

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

            $dataReader = (new App\Db\Query())->select(['tabid', 'fieldname'])

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

    class Settings_Picklist_Module_Model extends Settings_Vtiger_Module_Model

    There are no issues that match your filters.

    Category
    Status