YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/WebserviceUsers/services/WebserviceStandard.php

Summary

Maintainability
D
2 days
Test Coverage
F
7%

File WebserviceStandard.php has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * WebserviceStandard Record Model file.
 *
Severity: Minor
Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 3 hrs to fix

    The class Settings_WebserviceUsers_WebserviceStandard_Service has an overall complexity of 75 which is very high. The configured complexity threshold is 50.
    Open

    class Settings_WebserviceUsers_WebserviceStandard_Service extends Settings_WebserviceUsers_Record_Model
    {
        /** @var string Table name. */
        public $baseTable = 'w_#__api_user';
    
    

    Function getDisplayValue has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getDisplayValue($name)
        {
            $value = $this->get($name);
            switch ($name) {
                case 'server_id':
    Severity: Minor
    Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.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 getFieldInstanceByName has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFieldInstanceByName($name)
        {
            $moduleName = $this->getModule()->getName(true);
            $fieldsLabel = $this->getEditFields();
            $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];
    Severity: Major
    Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 2 hrs to fix

      Method getDisplayValue has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getDisplayValue($name)
          {
              $value = $this->get($name);
              switch ($name) {
                  case 'server_id':
      Severity: Major
      Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 2 hrs to fix

        Function getFieldInstanceByName has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFieldInstanceByName($name)
            {
                $moduleName = $this->getModule()->getName(true);
                $fieldsLabel = $this->getEditFields();
                $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];
        Severity: Minor
        Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 1 hr 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 getRecordLinks has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getRecordLinks(): array
            {
                $links = [];
                $recordLinks = [
                    [
        Severity: Minor
        Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 1 hr to fix

          Function setDataFromRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function setDataFromRequest(App\Request $request)
              {
                  foreach (array_keys($this->getEditFields()) as $field) {
                      if ($request->has($field)) {
                          switch ($field) {
          Severity: Minor
          Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 1 hr 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 setDataFromRequest has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function setDataFromRequest(App\Request $request)
              {
                  foreach (array_keys($this->getEditFields()) as $field) {
                      if ($request->has($field)) {
                          switch ($field) {
          Severity: Minor
          Found in modules/Settings/WebserviceUsers/services/WebserviceStandard.php - About 1 hr to fix

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

                public function getDisplayValue($name)
                {
                    $value = $this->get($name);
                    switch ($name) {
                        case 'server_id':

            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

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

                public function getFieldInstanceByName($name)
                {
                    $moduleName = $this->getModule()->getName(true);
                    $fieldsLabel = $this->getEditFields();
                    $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

            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

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

                public function setDataFromRequest(App\Request $request)
                {
                    foreach (array_keys($this->getEditFields()) as $field) {
                        if ($request->has($field)) {
                            switch ($field) {

            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 29 to the 15 allowed.
            Open

                public function getDisplayValue($name)

            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

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

                                        $value .= \App\Language::translate(Settings_WebserviceUsers_Record_Model::$customParamsLabels[$key], 'Settings:WebserviceUsers') . ": $row \n";

            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 undefined variables such as '$customParamsLabels' which will lead to PHP notices.
            Open

                                    if (isset(Settings_WebserviceUsers_Record_Model::$customParamsLabels[$key])) {

            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

            The class Settings_WebserviceUsers_WebserviceStandard_Service has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13.
            Open

            class Settings_WebserviceUsers_WebserviceStandard_Service extends Settings_WebserviceUsers_Record_Model
            {
                /** @var string Table name. */
                public $baseTable = 'w_#__api_user';
            
            

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Missing class import via use statement (line '174', column '18').
            Open

                                        throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

            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 '196', column '17').
            Open

                    $query = (new \App\Db\Query())->from($this->baseTable)->where(['server_id' => $this->get('server_id'), 'user_name' => $this->get('user_name')]);

            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 '180', column '16').
            Open

                                throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

            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\Record' in method 'getDisplayValue'.
            Open

                                $moduleName = \App\Record::getType($value);

            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 'getDisplayValue'.
            Open

                            $value = \App\Language::translate($value, 'Users');

            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_WebserviceApps_Module_Model' in method 'getFieldInstanceByName'.
            Open

                            $servers = Settings_WebserviceApps_Module_Model::getActiveServers($this->getModule()->typeApi);

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

                            } else {
                                $value = '';
                            }

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

                                        $value .= \App\Language::translate(Settings_WebserviceUsers_Record_Model::$customParamsLabels[$key], 'Settings:WebserviceUsers') . ": $row \n";

            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 'getFieldInstanceByName'.
            Open

                                $params['picklistValues'][$key] = \App\Language::translate($value, $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\Purifier' in method 'getDisplayValue'.
            Open

                            $value = $servers ? \App\Purifier::encodeHtml($servers->getName()) : '<span class="redColor">ERROR</span>';

            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\TextUtils' in method 'getDisplayValue'.
            Open

                            $value = \App\TextUtils::textTruncate($label);

            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 'getDisplayValue'.
            Open

                            $label = \App\Language::translate($this->getTypeValues($value), $this->getModule()->getName(true));

            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 'getFieldInstanceByName'.
            Open

                            $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

            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 'getFieldInstanceByName'.
            Open

                                'PLL_PASSWORD' => \App\Language::translate('PLL_PASSWORD', 'Users'),

            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 'getFieldInstanceByName'.
            Open

                                '-' => \App\Language::translate('LBL_NONE'),

            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_Vtiger_Field_Model' in method 'getFieldInstanceByName'.
            Open

                    return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

            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_Link_Model' in method 'getRecordLinks'.
            Open

                        $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);

            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\Json' in method 'getDisplayValue'.
            Open

                                $params = \App\Json::decode($value);

            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\Owner' in method 'getDisplayValue'.
            Open

                            $value = \App\Fields\Owner::getLabel($value);

            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 'getDisplayValue'.
            Open

                                            $row = $row ? \App\Language::getLanguageLabel($row) : '';

            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\Record' in method 'getDisplayValue'.
            Open

                                $label = \App\Record::getLabel($value) ?: '';

            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 'getDisplayValue'.
            Open

                                            $row = \App\Purifier::encodeHtml($row);

            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\Config' in method 'save'.
            Open

                    if ($result && $this->isNew() && \App\Config::api('enableEmailPortal', false)) {

            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\Mailer' in method 'sendEmail'.
            Open

                        \App\Mailer::sendFromTemplate([
                            'template' => 'YetiPortalRegister',
                            'moduleName' => $moduleName,
                            'recordId' => $this->get('crmid'),
                            'to' => $this->get('user_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

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

                                'PLL_AUTHY_TOTP' => \App\Language::translate('PLL_AUTHY_TOTP', 'Users'),

            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\Encryption' in method 'getValueToSave'.
            Open

                            $value = App\Encryption::createPasswordHash($value, 'WebserviceStandard');

            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_WebserviceApps_Record_Model' in method 'getDisplayValue'.
            Open

                            $servers = Settings_WebserviceApps_Record_Model::getInstanceById($value);

            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 'getDisplayValue'.
            Open

                            $value = \App\Language::translate((empty($value) ? 'FL_INACTIVE' : 'FL_ACTIVE'));

            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\DateTime' in method 'getDisplayValue'.
            Open

                            $value = \App\Fields\DateTime::formatToDisplay($value);

            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\Layout' in method 'getDisplayValue'.
            Open

                                $value = \App\Layout::truncateText($value, 50, true);

            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_Record_Model' in method 'sendEmail'.
            Open

                    $recordModel = Vtiger_Record_Model::getInstanceById($this->get('crmid'), $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\Language' in method 'getFieldInstanceByName'.
            Open

                            $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

            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\DateTime' in method 'getDisplayValue'.
            Open

                                            $row = \App\Fields\DateTime::formatToDisplay($row);

            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 'getDisplayValue'.
            Open

                            $value = \App\Purifier::encodeHtml($value);

            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 'getFieldInstanceByName'.
            Open

                            $params['picklistValues'] = \App\Language::getAll();

            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 'getFieldInstanceByName'.
            Open

                                'PLL_PASSWORD_2FA' => \App\Language::translate('PLL_PASSWORD_2FA', 'Users'),

            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 "typeofdata" 4 times.
            Open

                    $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

            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 "btn btn-sm btn-primary" 3 times.
            Open

                            'linkclass' => 'btn btn-sm btn-primary',

            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 "language" 5 times.
            Open

                    'language' => 'FL_LANGUAGE',

            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 "FL_STATUS" 3 times.
            Open

                    'status' => 'FL_STATUS',

            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.

            Add a "case default" clause to this "switch" statement.
            Open

                    switch ($key) {

            The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

            Noncompliant Code Example

            switch ($param) {  //missing default clause
              case 0:
                do_something();
                break;
              case 1:
                do_something_else();
                break;
            }
            
            switch ($param) {
              default: // default clause should be the last one
                error();
                break;
              case 0:
                do_something();
                break;
              case 1:
                do_something_else();
                break;
            }
            

            Compliant Solution

            switch ($param) {
              case 0:
                do_something();
                break;
              case 1:
                do_something_else();
                break;
              default:
                error();
                break;
            }
            

            See

            • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
            • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
            • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
            • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
            • MISRA C:2012, 16.1 - All switch statements shall be well-formed
            • MISRA C:2012, 16.4 - Every switch statement shall have a default label
            • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
            • MITRE, CWE-478 - Missing Default Case in Switch Statement
            • CERT, MSC01-C. - Strive for logical completeness
            • CERT, MSC01-CPP. - Strive for logical completeness

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

                                'PLL_PASSWORD' => \App\Language::translate('PLL_PASSWORD', 'Users'),

            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 "linklabel" 4 times.
            Open

                            'linklabel' => 'LBL_HISTORY_ACTIVITY',

            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 "uitype" 10 times.
            Open

                    $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

            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 "linktype" 4 times.
            Open

                            'linktype' => 'LISTVIEWRECORD',

            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 "status" 7 times.
            Open

                    'status' => 'FL_STATUS',

            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 "user_id" 6 times.
            Open

                    'user_id' => 'FL_USER',

            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 "authy_methods" 3 times.
            Open

                    'authy_methods' => 'FL_AUTHY_METHODS',

            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 "picklistValues" 9 times.
            Open

                            $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

            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 "LISTVIEWRECORD" 4 times.
            Open

                            'linktype' => 'LISTVIEWRECORD',

            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 "&record=" 3 times.
            Open

                            'linkurl' => $this->getModule()->getHistoryAccessActivityUrl() . '&record=' . $this->getId(),

            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 "user_name" 6 times.
            Open

                    'user_name' => 'FL_LOGIN',

            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 "linkclass" 4 times.
            Open

                            'linkclass' => 'btn btn-sm btn-primary',

            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 "login_method" 5 times.
            Open

                    'login_method' => 'FL_LOGIN_METHOD',

            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 "server_id" 9 times.
            Open

                    'server_id' => 'FL_SERVER',

            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 "linkurl" 4 times.
            Open

                            'linkurl' => $this->getModule()->getHistoryAccessActivityUrl() . '&record=' . $this->getId(),

            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 "linkicon" 4 times.
            Open

                            'linkicon' => 'yfi yfi-login-history',

            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 "logout_time" 3 times.
            Open

                public $paramsFields = ['language', 'logout_time'];

            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 "crmid" 10 times.
            Open

                    'crmid' => 'FL_RECORD_NAME',

            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 "password" 8 times.
            Open

                    'password' => 'FL_PASSWORD',

            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 "modalView" 3 times.
            Open

                            'modalView' => true,

            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.

            Declaration of function getDisplayValue($name) should be compatible with function getDisplayValue(string $key) (parameter #1 with no type cannot replace original parameter with type 'string') defined in /code/modules/Settings/Vtiger/models/Record.php:52
            Open

                 * @param string $name

            Returning type \Vtiger_Field_Model but getFieldInstanceByName() is declared to return string[]
            Open

                    return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

            Returning type null but getFieldInstanceByName() is declared to return string[]
            Open

                    return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

            Call to method getInstance from undeclared class \App\Fields\Owner
            Open

                            $params['picklistValues'] = \App\Fields\Owner::getInstance($moduleName)->getAccessibleUsers('', 'owner');

            Method \Settings_WebserviceUsers_WebserviceStandard_Service::save is declared to return bool but has no return value
            Open

                public function save()

            Call to method getInstance from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
            Open

                    $data['password'] = App\Encryption::getInstance()->decrypt($data['password']);

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

                    $query = (new \App\Db\Query())->from($this->baseTable)->where(['server_id' => $this->get('server_id'), 'user_name' => $this->get('user_name')]);

            Call to method createPasswordHash from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
            Open

                            $value = App\Encryption::createPasswordHash($value, 'WebserviceStandard');

            Call to method getLabel from undeclared class \App\Fields\Owner
            Open

                            $value = \App\Fields\Owner::getLabel($value);

            Remove the code after this "throw".
            Open

                                throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

            Jump statements (return, break, continue, and goto) and throw expressions move control flow out of the current code block. Typically, any statements in a block that come after a jump or throw are simply wasted keystrokes lying in wait to confuse the unwary.

            Rarely, as illustrated below, code after a jump or throw is reachable. However, such code is difficult to understand, and should be refactored.

            Noncompliant Code Example

            function fun($a) {
              $i = 10;
              return $i + $a;
              $i++;             // this is never executed
            }
            
            function foo($a) {
              if ($a == 5) {
                goto error;
              } else {
                // do the job
              }
              return;
            
              error:
                printf("don't use 5"); // this is reachable but unreadable
            
            }
            

            Compliant Solution

            function fun($a) {
              $i = 10;
              return $i + $a;
            }
            
            function foo($a) {
              if ($a == 5) {
                handleError();
              } else {
                // do the job
              }
              return;
            }
            

            See

            • MISRA C:2004, 14.1 - There shall be no unreachable code
            • MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
            • MISRA C++:2008, 0-1-9 - There shall be no dead code
            • MISRA C:2012, 2.1 - A project shall not contain unreachable code
            • MISRA C:2012, 2.2 - There shall be no dead code
            • MITRE, CWE-561 - Dead Code
            • CERT, MSC56-J. - Detect and remove superfluous code and values
            • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
            • CERT, MSC07-CPP. - Detect and remove dead code

            Avoid excessively long class names like Settings_WebserviceUsers_WebserviceStandard_Service. Keep class name length under 40.
            Open

            class Settings_WebserviceUsers_WebserviceStandard_Service extends Settings_WebserviceUsers_Record_Model
            {
                /** @var string Table name. */
                public $baseTable = 'w_#__api_user';
            
            

            LongClassName

            Since: 2.9

            Detects when classes or interfaces are declared with excessively long names.

            Example

            class ATooLongClassNameThatHintsAtADesignProblem {
            
            }
            
            interface ATooLongInterfaceNameThatHintsAtADesignProblem {
            
            }

            Source https://phpmd.org/rules/naming.html#longclassname

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

            class Settings_WebserviceUsers_WebserviceStandard_Service extends Settings_WebserviceUsers_Record_Model

            The class Settings_WebserviceUsers_WebserviceStandard_Service is not named in CamelCase.
            Open

            class Settings_WebserviceUsers_WebserviceStandard_Service extends Settings_WebserviceUsers_Record_Model
            {
                /** @var string Table name. */
                public $baseTable = 'w_#__api_user';
            
            

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

            The DEFAULT body must start on the line following the statement
            Open

                        default: break;

            Terminating statement must be indented to the same level as the CASE body
            Open

                                throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

            Terminating statement must be on a line by itself
            Open

                        default: break;

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

                public $listFields = [

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

                    'time' => 'FL_LOGIN_TIME',

            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

                    $data['password'] = App\Encryption::getInstance()->decrypt($data['password']);

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

                    'status' => 'FL_STATUS',

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

                    'user_name' => 'FL_LOGIN',

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

                    'type' => 'FL_TYPE',

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

                /** @var array Columns to show on the list session. */

            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 $paramsFields = ['language', 'logout_time'];

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

                 * @param mixed $name

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

                /** @var string Table name. */

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

                /** @var string Table name. */

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

                    $this->setData($data);

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

                    'authy_methods' => 'FL_AUTHY_METHODS',

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

                public function init(array $data)

            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

                 *

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

                    'status' => 'FL_STATUS',

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

                    'login_method' => 'FL_LOGIN_METHOD',

            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

                    'user_id' => 'FL_USER',

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

                public $columnsToShow = [

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

                public $baseTable = 'w_#__api_user';

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

                public $editFields = [

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

                    'type' => 'FL_TYPE',

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

                    'ip' => 'LBL_IP_ADDRESS',

            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 string[]

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

                    'custom_params' => 'FL_CUSTOM_PARAMS',

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

                    'agent' => 'LBL_USER_AGENT',

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

                {

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

                    'user_id' => 'FL_USER',

            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

                    'login_method' => 'FL_LOGIN_METHOD',

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

                    'language' => 'FL_LANGUAGE',

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

                 * Function determines fields available in edition view.

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

                ];

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

                    'login_time' => 'FL_LOGIN_TIME',

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

                    'status' => 'FL_STATUS',

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

                        case 'crmid':

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

                            $params['uitype'] = 16;

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

                        case 'password':

            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

                 *

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

                public function getValueToSave($key, $value)

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

                    'password' => 'FL_PASSWORD',

            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

                public $baseIndex = 'id';

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

                    'server_id' => 'FL_SERVER',

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

                    'crmid' => 'FL_RECORD_NAME',

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

                    'server_id' => 'FL_SERVER',

            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

                    $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

                            break;

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

                            $params['uitype'] = 32;

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

                        case 'user_id':

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

                            $params['picklistValues'] = \App\Fields\Owner::getInstance($moduleName)->getAccessibleUsers('', 'owner');

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

                        case 'login_method':

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

                            $params['typeofdata'] = 'V~O';

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

                            $params['uitype'] = 99;

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

                            $params['typeofdata'] = 'V~O';

            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

                                    break;

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

                                    break;

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

                        case 'user_id':

            Line exceeds 120 characters; contains 193 characters
            Open

                    $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'label' => $fieldsLabel[$name], 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

                            $params['picklistValues'] = [

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

                            switch ($field) {

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

                                case 'server_id':

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

                                case 'type':

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

                                case 'login_method':

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

                            $this->set($field, $this->getValueToSave($field, $value));

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

                    $result = parent::checkData();

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

                    switch ($key) {

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

                        case 'status':

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

                            $params['uitype'] = 16;

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

                            $params['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

                            break;

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

                        case 'authy_methods':

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

                                case 'authy_methods':

            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

                    $query = (new \App\Db\Query())->from($this->baseTable)->where(['server_id' => $this->get('server_id'), 'user_name' => $this->get('user_name')]);

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

                    return !$result && $query->exists() ? 'LBL_DUPLICATE_LOGIN' : $result;

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

                public function getFieldInstanceByName($name)

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

                            $params['fieldparams'] = [

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

                            foreach ($this->getTypeValues() as $key => $value) {

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

                    return $params ? Settings_Vtiger_Field_Model::init($moduleName, $params) : null;

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

                {

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

                            $params['referenceList'] = ['Contacts'];

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

                                'PLL_PASSWORD' => \App\Language::translate('PLL_PASSWORD', 'Users'),

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

                                case 'status':

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

                        $query->andWhere(['<>', 'id', $this->getId()]);

            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 = $this->getModule()->getName(true);

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

                        case 'server_id':

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

                                $params = null;

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

                    }

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

                                case 'user_id':

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

                                case 'language':

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

                                    $value = $request->getRaw($field, null);

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

                                default:

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

                                throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

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

                 * @return int|string

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

                        case 'type':

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

                            $value = (int) $value;

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

                            $params['uitype'] = 10;

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

                            break;

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

                            $params['maximumlength'] = '100';

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

                 * @param App\Request $request

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

                                    $value = $request->isEmpty('crmid') ? '' : $request->getInteger('crmid');

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

                                    break;

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

                                    $value = $request->getByType($field, 'Text');

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

                /**

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

                            $params['uitype'] = 16;

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

                            break;

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

                public function setDataFromRequest(App\Request $request)

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

                                    $value = $request->getInteger($field);

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

                                case 'user_name':

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

                public function checkData()

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

                 * @param mixed  $value

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

                        case 'server_id':

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

                 */

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

                            $params['uitype'] = 16;

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

                                'PLL_PASSWORD_2FA' => \App\Language::translate('PLL_PASSWORD_2FA', 'Users'),

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

                            $params['uitype'] = 16;

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

                            ];

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

                 * Sets data from request.

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

                 * Check if the data is correct.

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

                 * @param string $key

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

                        case 'status':

            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

                            $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

                            $params['uitype'] = 16;

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

                                '-' => \App\Language::translate('LBL_NONE'),

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

                                'PLL_AUTHY_TOTP' => \App\Language::translate('PLL_AUTHY_TOTP', 'Users'),

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

                            if ($this->has('id')) {

            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

                    foreach (array_keys($this->getEditFields()) as $field) {

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

                                    if (!$this->isNew()) {

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

                            }

            Line exceeds 120 characters; contains 152 characters
            Open

                    $query = (new \App\Db\Query())->from($this->baseTable)->where(['server_id' => $this->get('server_id'), 'user_name' => $this->get('user_name')]);

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

                    $fieldsLabel = $this->getEditFields();

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

                                'searchParams' => '[[["email","ny",""]]]',

            Line exceeds 120 characters; contains 135 characters
            Open

                            $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

                            $servers = Settings_WebserviceApps_Module_Model::getActiveServers($this->getModule()->typeApi);

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

                            }

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

                        case 'type':

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

                            $params['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

                            break;

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

                            }

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

                                case 'crmid':

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

                                    parent::set($field, $value);

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

                 */

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

                        case 'crmid':

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

                            break;

            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 ($value) {

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

                                        case 'error_time':

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

                                        default:

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

                            break;

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

                            'modalView' => 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

                            'linkicon' => 'fas fa-trash-alt',

            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 string|string[]

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

                }

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

                        case 'language':

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

                            $params['typeofdata'] = 'V~O';

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

                                        throw new \App\Exceptions\Security("ERR_ILLEGAL_FIELD_VALUE||{$field}", 406);

            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 formats data for saving.

            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 = \App\Record::getType($value);

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

                            $value = \App\Fields\DateTime::formatToDisplay($value);

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

                                        case 'language':

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

                                            $row = $row ? \App\Language::getLanguageLabel($row) : '';

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

                            'linkicon' => 'yfi yfi-login-history',

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

                            'linkurl' => $this->getModule()->getEditViewUrl() . '&record=' . $this->getId(),

            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

                            $params['picklistValues'] = [];

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

                                $params['picklistValues'][$key] = $value['name'];

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

                            $params['picklistValues'] = \App\Language::getAll();

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

                            $params['typeApi'] = $this->getModule()->typeApi;

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

                        if ($request->has($field)) {

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

                                    break;

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

                                    break;

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

                    if ($this->getId()) {

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

                                foreach ($params as $key => $row) {

            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

                            'linkurl' => $this->getModule()->getHistoryAccessActivityUrl() . '&record=' . $this->getId(),

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

                            'linktype' => 'LISTVIEWRECORD',

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

                    $value = $this->get($name);

            Line exceeds 120 characters; contains 123 characters
            Open

                            $value = $servers ? \App\Purifier::encodeHtml($servers->getName()) : '<span class="redColor">ERROR</span>';

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

                                $value = \App\Layout::truncateText($value, 50, true);

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

                            'linklabel' => 'LBL_HISTORY_ACTIVITY',

            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 string

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

                            $value = \App\Language::translate((empty($value) ? 'FL_INACTIVE' : 'FL_ACTIVE'));

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

                        case 'user_id':

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

                            $value = \App\TextUtils::textTruncate($label);

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

                {

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

                            'linktype' => 'LISTVIEWRECORD',

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

                            'linklabel' => 'LBL_EDIT_RECORD',

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

                    foreach ($recordLinks as $recordLink) {

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

                public function getDisplayValue($name)

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

                            break;

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

                            if ($value) {

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

                                $url = "index.php?module={$moduleName}&view=Detail&record={$value}";

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

                        case 'login_method':

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

                            $label = \App\Language::translate($this->getTypeValues($value), $this->getModule()->getName(true));

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

                                    switch ($key) {

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

                                        $value .= \App\Language::translate(Settings_WebserviceUsers_Record_Model::$customParamsLabels[$key], 'Settings:WebserviceUsers') . ": $row \n";

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

                            $value = \App\Purifier::encodeHtml($value);

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

                            'linkclass' => 'btn btn-sm btn-primary',

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

                        [

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

                            'linkclass' => 'btn btn-sm btn-primary',

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

                            'linkclass' => 'btn btn-sm btn-primary',

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

                            'linkurl' => 'javascript:Settings_WebserviceUsers_List_Js.deleteById(' . $this->getId() . ');',

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

                        ],

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

                        $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);

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

                 * Type field values.

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

                    switch ($name) {

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

                            break;

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

                            foreach ($servers as $key => $value) {

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

                            break;

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

                                $params['picklistValues'][$key] = \App\Language::translate($value, $moduleName);

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

                            break;

            Line exceeds 120 characters; contains 121 characters
            Open

                            $params['picklistValues'] = \App\Fields\Owner::getInstance($moduleName)->getAccessibleUsers('', 'owner');

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

                            break;

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

                            $params['fieldparams'] = '{"validate":["pwned","config"],"auto-generate":true,"strengthMeter":true}';

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

                        default: break;

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

                                case 'password':

            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 bool|string

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

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

                        case 'type':

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

                                $value = '';

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

                                            $row = \App\Fields\DateTime::formatToDisplay($row);

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

                                    if (isset(Settings_WebserviceUsers_Record_Model::$customParamsLabels[$key])) {

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

                    return $links;

            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 ($value) {

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

                public function save()

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

                        case 'password':

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

                            $servers = Settings_WebserviceApps_Record_Model::getInstanceById($value);

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

                            break;

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

                            $value = \App\Language::translate($value, 'Users');

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

                                            break;

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

                    $recordLinks = [

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

                            'linklabel' => 'LBL_SESSION_RECORD',

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

                        \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS => 'PLL_ACCOUNTS_RELATED_RECORDS',

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

                    return $data;

            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

                public function sendEmail()

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

                            break;

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

                 *

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

                            break;

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

                        case 'login_time':

            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 getRecordLinks(): array

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

                            'linktype' => 'LISTVIEWRECORD',

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

                            'linkicon' => 'fas fa-users-cog',

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

                        ],

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

                            'linkclass' => 'btn btn-sm btn-danger',

            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

                        case 'server_id':

            Line exceeds 120 characters; contains 151 characters
            Open

                        \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY => 'PLL_ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY',

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

                        \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY => 'PLL_ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY',

            Line exceeds 120 characters; contains 133 characters
            Open

                                $value = "<a class='modCT_{$moduleName} showReferenceTooltip js-popover-tooltip--record' href='$url'>$label</a>";

            Line exceeds 120 characters; contains 131 characters
            Open

                        \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY => 'PLL_ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY',

            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

                        case 'custom_params':

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

                                            break;

            Line exceeds 120 characters; contains 171 characters
            Open

                                        $value .= \App\Language::translate(Settings_WebserviceUsers_Record_Model::$customParamsLabels[$key], 'Settings:WebserviceUsers') . ": $row \n";

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

                            'modalView' => 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

                        \Api\WebservicePremium\Privilege::USER_PERMISSIONS => 'PLL_USER_PERMISSIONS',

            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->sendEmail();

            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

                            'to' => $this->get('user_name'),

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

                            'login' => $this->get('user_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

                            'linkurl' => $this->getModule()->getSessionViewUrl() . '&record=' . $this->getId(),

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

                        return $data[$value];

            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 (empty($this->get('crmid'))) {

            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

                    $moduleName = 'Contacts';

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

                    if ($recordModel->get('emailoptout')) {

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

                            }

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

                            break;

            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

                {

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

                 * Function to get the Display Value, for the current field type with given DB Insert Value.

            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

                                $value = '';

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

                            break;

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

                            break;

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

                                        case 'logout_time':

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

                            }

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

                            'linkicon' => 'yfi yfi-full-editing-view',

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

                        \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY => 'PLL_ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY',

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

                            $value = App\Encryption::createPasswordHash($value, 'WebserviceStandard');

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

                    switch ($name) {

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

                            $value = $servers ? \App\Purifier::encodeHtml($servers->getName()) : '<span class="redColor">ERROR</span>';

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

                        case 'status':

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

                            $value = \App\Fields\Owner::getLabel($value);

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

                        case 'logout_time':

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

                                $params = \App\Json::decode($value);

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

                                        case 'invalid_login_time':

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

                                    }

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

                            break;

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

                            'modalView' => true,

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

                            'linktype' => 'LISTVIEWRECORD',

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

                            'linklabel' => 'LBL_DELETE_RECORD',

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

                {

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

                    $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

                            'recordId' => $this->get('crmid'),

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

                            'acceptable_url' => Settings_WebserviceApps_Record_Model::getInstanceById($this->get('server_id'))->get('url'),

            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

                                $label = \App\Record::getLabel($value) ?: '';

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

                                $value = "<a class='modCT_{$moduleName} showReferenceTooltip js-popover-tooltip--record' href='$url'>$label</a>";

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

                                            break;

            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

                    $links = [];

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

                 * @param mixed|null $value

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

                    $result = parent::save();

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

                    if ($result && $this->isNew() && \App\Config::api('enableEmailPortal', false)) {

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

                        \App\Mailer::sendFromTemplate([

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

                            'moduleName' => $moduleName,

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

                            'password' => $this->changes['password'],

            Line exceeds 120 characters; contains 127 characters
            Open

                            'acceptable_url' => Settings_WebserviceApps_Record_Model::getInstanceById($this->get('server_id'))->get('url'),

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

                 *

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

                        case 'crmid':

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

                        case 'istorage':

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

                            break;

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

                                            $row = \App\Purifier::encodeHtml($row);

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

                        default:

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

                    return $value;

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

                public function getTypeValues($value = null)

            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

                    $recordModel = Vtiger_Record_Model::getInstanceById($this->get('crmid'), $moduleName);

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

                            'template' => 'YetiPortalRegister',

            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

                 * Send mails with access.

            Closing brace must be on a line by itself
            Open

                        default: break;

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

            class Settings_WebserviceUsers_WebserviceStandard_Service extends Settings_WebserviceUsers_Record_Model

            There are no issues that match your filters.

            Category
            Status