YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/BusinessHours/models/Record.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

Method validate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function validate(array $data): array
    {
        if (isset($data['id'])) {
            $data['id'] = \App\Purifier::purifyByType($data['id'], 'Integer');
        }
Severity: Minor
Found in modules/Settings/BusinessHours/models/Record.php - About 1 hr to fix

    Function validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function validate(array $data): array
        {
            if (isset($data['id'])) {
                $data['id'] = \App\Purifier::purifyByType($data['id'], 'Integer');
            }
    Severity: Minor
    Found in modules/Settings/BusinessHours/models/Record.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

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

        public function getDisplayValue(string $key): string
        {
            $value = $this->get($key);
            if ('working_days' === $key) {
                $days = explode(',', trim($value, ','));
    Severity: Minor
    Found in modules/Settings/BusinessHours/models/Record.php - About 55 mins 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

    The method validate() has an NPath complexity of 512. The configured NPath complexity threshold is 200.
    Open

        public static function validate(array $data): array
        {
            if (isset($data['id'])) {
                $data['id'] = \App\Purifier::purifyByType($data['id'], 'Integer');
            }

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

        public static function validate(array $data): array
        {
            if (isset($data['id'])) {
                $data['id'] = \App\Purifier::purifyByType($data['id'], 'Integer');
            }

    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 getDisplayValue() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
    Open

        public function getDisplayValue(string $key): string
        {
            $value = $this->get($key);
            if ('working_days' === $key) {
                $days = explode(',', trim($value, ','));

    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 class Settings_BusinessHours_Record_Model has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
    Open

    class Settings_BusinessHours_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Function to get the Id.
         *

    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 '148', column '14').
    Open

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['working_days'], 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 '161', column '14').
    Open

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['holidays'], 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

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

        public function getEditViewUrl($step = false): string

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Missing class import via use statement (line '154', column '15').
    Open

                    throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $day, 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 '145', column '14').
    Open

                throw new \App\Exceptions\AppException('ERR_EXCEEDED_NUMBER_CHARACTERS||255', 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 '97', column '15').
    Open

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

    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 '124', column '24').
    Open

                $this->module = new Settings_BusinessHours_Module_Model();

    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 '164', column '14').
    Open

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['default'], 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\Db' in method 'getInstanceById'.
    Open

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

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

            $data['name'] = \App\Purifier::purifyByType($data['name'], 'Text');

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

                $data['id'] = \App\Purifier::purifyByType($data['id'], 'Integer');

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

            if (\App\TextUtils::getTextLength($data['name']) > 254) {

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

            $data['working_hours_from'] = \App\Purifier::purifyByType($data['working_hours_from'], 'time');

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

            $data['resolve_time'] = \App\Purifier::purifyByType($data['resolve_time'], 'timePeriod');

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\App\Db' in method 'save'.
    Open

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

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

                $value = \App\Fields\Time::formatToDisplay($value, 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\Language' in method 'getDisplayValue'.
    Open

                $value = $value ? \App\Language::translate('LBL_YES') : \App\Language::translate('LBL_NO');

    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 = \App\Purifier::encodeHtml($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 assigning values to variables in if clauses and the like (line '49', column '7').
    Open

        public function set($key, $value)
        {
            if ($oldValue = $this->get($key)) {
                $this->oldValues[$key] = $oldValue;
            }

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    Avoid using static access to class '\App\Purifier' in method 'validate'.
    Open

            $data['working_hours_to'] = \App\Purifier::purifyByType($data['working_hours_to'], 'time');

    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(array_flip(\App\Fields\Date::$dayOfWeek)[$day], 'Calendar');

    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 = $value ? \App\Language::translate('LBL_HOLIDAYS', 'Settings:BusinessHours') : '';

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

                $days[$index] = \App\Purifier::purifyByType($day, 'Integer');

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

            } else {
                $db->createCommand()->insert('s_#__business_hours', $data)->execute();
            }

    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 = $value ? \App\Language::translate('LBL_YES') : \App\Language::translate('LBL_NO');

    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\Cache' in method 'delete'.
    Open

                \App\Cache::clear();

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

            $data['reaction_time'] = \App\Purifier::purifyByType($data['reaction_time'], 'timePeriod');

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

            $data['idle_time'] = \App\Purifier::purifyByType($data['idle_time'], 'timePeriod');

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

            \App\Cache::clear();

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

                $value = \App\Fields\TimePeriod::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

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

            $data['resolve_time'] = \App\Purifier::purifyByType($data['resolve_time'], 'timePeriod');

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

            $data['reaction_time'] = \App\Purifier::purifyByType($data['reaction_time'], 'timePeriod');

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

            if (isset($data['default']) && 0 !== $data['default'] && 1 !== $data['default']) {

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

            if (isset($data['holidays']) && 0 !== $data['holidays'] && 1 !== $data['holidays']) {

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

            if (!\is_string($data['working_days'])) {

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

            $data['reaction_time'] = \App\Purifier::purifyByType($data['reaction_time'], 'timePeriod');

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

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

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

            $data['working_hours_to'] = \App\Purifier::purifyByType($data['working_hours_to'], '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 "working_hours_from" 3 times.
    Open

            $data['working_hours_from'] = \App\Purifier::purifyByType($data['working_hours_from'], '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 "s_#__business_hours" 4 times.
    Open

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

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

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['working_days'], 406);

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

            $data['idle_time'] = \App\Purifier::purifyByType($data['idle_time'], 'timePeriod');

    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.

    Avoid unused parameters such as '$step'.
    Open

        public function getEditViewUrl($step = false): string

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

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

    Reference to undeclared property \Settings_BusinessHours_Record_Model->module
    Open

                $this->module = new Settings_BusinessHours_Module_Model();

    Reference to undeclared property \Settings_BusinessHours_Record_Model->module
    Open

            if (!isset($this->module)) {

    Reference to undeclared property \Settings_BusinessHours_Record_Model->module
    Open

            return $this->module;

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

                $db->createCommand()->update('s_#__business_hours', $data, ['id' => $recordId])->execute();

    Reference to undeclared property \Settings_BusinessHours_Record_Model->oldValues (Did you mean $oldValue)
    Open

                $this->oldValues[$key] = $oldValue;

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

                $db->createCommand()->insert('s_#__business_hours', $data)->execute();

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

            $delete = \App\Db::getInstance('admin')->createCommand()

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

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

    Return type of getInstanceById() is undeclared type \self
    Open

        public static function getInstanceById(int $id)

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        public function getRecordLinks(): array
        {
            $links = [];
            $recordLinks = [
                [
    Severity: Major
    Found in modules/Settings/BusinessHours/models/Record.php and 3 other locations - About 1 hr to fix
    modules/Settings/AutomaticAssignment/models/Record.php on lines 213..236
    modules/Settings/Groups/models/Record.php on lines 420..443
    modules/Settings/TreesManager/models/Record.php on lines 97..120

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 117.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    class Settings_BusinessHours_Record_Model extends Settings_Vtiger_Record_Model

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

        protected function setId(int $id): self

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

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

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

        public static function getInstanceById(int $id)

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

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

    The class Settings_BusinessHours_Record_Model is not named in CamelCase.
    Open

    class Settings_BusinessHours_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Function to get the Id.
         *

    CamelCaseClassName

    Since: 0.2

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

    Example

    class class_name {
    }

    Source

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

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

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

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

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

         *

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

        {

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

        {

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

            if ($oldValue = $this->get($key)) {

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

         * Function to get the Id.

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

         * @return int|null Id

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

         * Function to get the Id.

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

         * @return self

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

        }

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

         * @return string|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

            return '?module=BusinessHours&parent=Settings&view=Edit&record=' . $this->getId();

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

        public function getDetailViewUrl(): 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

            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

         *

    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 Edit View 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

            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

        {

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

                $this->oldValues[$key] = $oldValue;

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

         * @return string URL

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

         * @return string 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

        protected function setId(int $id): self

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

            return $this->get('name');

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

         *

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

        {

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

        /**

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

            return $this->get('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

         *

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

         *

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

         * @param mixed $step

    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 getName()

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

        /** {@inheritdoc} */

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

        public function set($key, $value)

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

            return '?module=BusinessHours&parent=Settings&view=Edit&record=' . $this->getId();

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

        public function 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

        public function getEditViewUrl($step = false): 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

            $instance = false;

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

            return new static();

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

        public static function validate(array $data): array

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

            if (isset($data['id'])) {

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

            $data['name'] = \App\Purifier::purifyByType($data['name'], 'Text');

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

            if (isset($data['holidays']) && 0 !== $data['holidays'] && 1 !== $data['holidays']) {

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

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['default'], 406);

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

            $data['resolve_time'] = \App\Purifier::purifyByType($data['resolve_time'], 'timePeriod');

    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

            } elseif ('working_hours_from' === $key || 'working_hours_to' === $key) {

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

            } elseif ('default' === $key) {

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

            } elseif ('holidays' === $key) {

    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

            $delete = \App\Db::getInstance('admin')->createCommand()

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

                ->delete('s_#__business_hours', ['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

         * @param int $id

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

            $this->set('id', $id);

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

         * Function to get the 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

         * Function to get the Delete Action Url for the current profile.

    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

         * @param array $data

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

         * @throws \App\Exceptions\AppException

    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

                $days[$index] = \App\Purifier::purifyByType($day, 'Integer');

    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

        }

    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 Detail 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

         * Validate record data.

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

         * @return array

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

            $data['working_hours_from'] = \App\Purifier::purifyByType($data['working_hours_from'], 'time');

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

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

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

                $db->createCommand()->update('s_#__business_hours', $data, ['id' => $recordId])->execute();

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

                }

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

            } elseif ('reaction_time' === $key || 'idle_time' === $key || 'resolve_time' === $key) {

    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

        /**

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

            parent::set($key, $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

         */

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

        public function getModule(): Settings_BusinessHours_Module_Model

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

                    throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $day, 406);

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

            $data['reaction_time'] = \App\Purifier::purifyByType($data['reaction_time'], 'timePeriod');

    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

            \App\Cache::clear();

    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

                $days = explode(',', trim($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

         *

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

            return '?module=BusinessHours&parent=Settings&view=DeleteAjax&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

         *

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

    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

                    'linkurl' => $this->getEditViewUrl(),

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

                    'linkurl' => 'javascript:Settings_BusinessHours_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

         * @return \self instance, if exists

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

        public static function getInstanceById(int $id)

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

            if ($row) {

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

         * @return Settings_BusinessHours_Module_Model

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

         *

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

            if (\App\TextUtils::getTextLength($data['name']) > 254) {

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

            if (!\is_string($data['working_days'])) {

    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 = static::validate($this->getData());

    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

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

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

         * @return bool

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

            return $delete;

    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

                    'linktype' => 'LISTVIEWRECORD',

    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 static function getCleanInstance(): self

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

        {

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

            return $this->module;

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

        }

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

                $data['id'] = \App\Purifier::purifyByType($data['id'], 'Integer');

    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 save.

    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 getDisplayValue(string $key): string

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

                $value = $value ? \App\Language::translate('LBL_YES') : \App\Language::translate('LBL_NO');

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

        /**

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

         *

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

            if (!isset($this->module)) {

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

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['working_days'], 406);

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

            foreach ($days as $index => $day) {

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

            if (!isset($data['default'])) {

    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

                $value = \App\Fields\Time::formatToDisplay($value, false);

    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

                    'linklabel' => 'LBL_EDIT_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

                throw new \App\Exceptions\AppException('ERR_EXCEEDED_NUMBER_CHARACTERS||255', 406);

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

            if (isset($data['default']) && 0 !== $data['default'] && 1 !== $data['default']) {

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

            $data['idle_time'] = \App\Purifier::purifyByType($data['idle_time'], 'timePeriod');

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

         *

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

         * @param int $id

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

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

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

                $instance->setData($row);

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

            return $instance;

    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

                foreach ($days as $day) {

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

                $value = implode(', ', $value);

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

         * Function to delete the current Record Model.

    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

            $recordLinks = [

    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

            $data['working_days'] = implode(',', $days);

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

            $data['working_hours_to'] = \App\Purifier::purifyByType($data['working_hours_to'], 'time');

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

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

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

                ->execute();

    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

         * @return string

    Line exceeds 120 characters; contains 124 characters
    Open

            $row = (new \App\Db\Query())->from('s_#__business_hours')->where(['id' => $id])->one(\App\Db::getInstance('admin'));

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

         * function to get clean instance.

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

            }

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

            $days = explode(',', trim($data['working_days'], ','));

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

                $data['holidays'] = 0;

    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 ($recordLinks as $recordLink) {

    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

                \App\Cache::clear();

    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

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

    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 \static

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

         */

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

            if (!isset($data['holidays'])) {

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

                $data['default'] = 0;

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

         */

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

                $value = $value ? \App\Language::translate('LBL_HOLIDAYS', 'Settings:BusinessHours') : '';

    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

            if ($delete) {

    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

        }

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

         * Function to get Module instance.

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

                if ((int) $day < 1 || (int) $day > 7) {

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

                throw new \App\Exceptions\AppException('ERR_NOT_ALLOWED_VALUE||' . $data['holidays'], 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

        /**

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

                $db->createCommand()->insert('s_#__business_hours', $data)->execute();

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

            }

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

         */

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

        /** {@inheritdoc} */

    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

        public function getDeleteActionUrl(): string

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

         * Function to get the instance of companies record model.

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

         *

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

        {

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

                $instance = new self();

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

        }

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

            $recordId = $this->getId();

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

            } else {

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

        {

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

         */

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

                $this->module = new Settings_BusinessHours_Module_Model();

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

            }

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

         *

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

            }

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

            return $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

            if ('working_days' === $key) {

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

                    $value[] = \App\Language::translate(array_flip(\App\Fields\Date::$dayOfWeek)[$day], 'Calendar');

    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 delete(): bool

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

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

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

    class Settings_BusinessHours_Record_Model extends Settings_Vtiger_Record_Model

    There are no issues that match your filters.

    Category
    Status