YetiForceCompany/YetiForceCRM

View on GitHub
modules/com_vtiger_workflow/WorkFlowScheduler.php

Summary

Maintainability
D
1 day
Test Coverage
F
14%

Function queueScheduledWorkflowTasks has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function queueScheduledWorkflowTasks()
    {
        $default_timezone = App\Config::main('default_timezone');
        $vtWorflowManager = new VTWorkflowManager();
        $taskQueue = new VTTaskQueue();
Severity: Minor
Found in modules/com_vtiger_workflow/WorkFlowScheduler.php - About 4 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 addWorkflowConditionsToQueryGenerator has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addWorkflowConditionsToQueryGenerator(App\QueryGenerator $queryGenerator, $conditions)
    {
        $conditionMapping = [
            'equal to' => 'e',
            'less than' => 'l',
Severity: Major
Found in modules/com_vtiger_workflow/WorkFlowScheduler.php - About 2 hrs to fix

    Function addWorkflowConditionsToQueryGenerator has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addWorkflowConditionsToQueryGenerator(App\QueryGenerator $queryGenerator, $conditions)
        {
            $conditionMapping = [
                'equal to' => 'e',
                'less than' => 'l',
    Severity: Minor
    Found in modules/com_vtiger_workflow/WorkFlowScheduler.php - About 2 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 parseValueForDate has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function parseValueForDate($condition)
        {
            $value = $condition['value'];
            $operation = $condition['operation'];
    
    
    Severity: Major
    Found in modules/com_vtiger_workflow/WorkFlowScheduler.php - About 2 hrs to fix

      Function parseValueForDate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parseValueForDate($condition)
          {
              $value = $condition['value'];
              $operation = $condition['operation'];
      
      
      Severity: Minor
      Found in modules/com_vtiger_workflow/WorkFlowScheduler.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 queueScheduledWorkflowTasks has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function queueScheduledWorkflowTasks()
          {
              $default_timezone = App\Config::main('default_timezone');
              $vtWorflowManager = new VTWorkflowManager();
              $taskQueue = new VTTaskQueue();
      Severity: Minor
      Found in modules/com_vtiger_workflow/WorkFlowScheduler.php - About 1 hr to fix

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

            public function queueScheduledWorkflowTasks()
            {
                $default_timezone = App\Config::main('default_timezone');
                $vtWorflowManager = new VTWorkflowManager();
                $taskQueue = new VTTaskQueue();

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

            public function parseValueForDate($condition)
            {
                $value = $condition['value'];
                $operation = $condition['operation'];
        
        

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

            public function queueScheduledWorkflowTasks()

        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

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

            public function addWorkflowConditionsToQueryGenerator(App\QueryGenerator $queryGenerator, $conditions)

        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

        Missing class import via use statement (line '74', column '20').
        Open

                $taskQueue = new VTTaskQueue();

        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 '48', column '25').
        Open

                $queryGenerator = new \App\QueryGenerator($moduleName, $this->user->id);

        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 '73', column '27').
        Open

                $vtWorflowManager = new VTWorkflowManager();

        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 'Users' in method 'queueScheduledWorkflowTasks'.
        Open

                $admin = Users::getActiveAdminUser();

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

                $conditions = \App\Json::decode(App\Purifier::decodeHtml($workflow->test));

        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 'Users' in method '__construct'.
        Open

                $this->user = Users::getActiveAdminUser();

        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_Workflows_Record_Model' in method 'queueScheduledWorkflowTasks'.
        Open

                    $workflowRecord = Settings_Workflows_Record_Model::getInstanceFromWorkflowObject($workflow);

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

                                    } else {
                                        $trigger = $taskRecord->getTaskObject()->trigger;
                                        $delay = null !== $trigger ? strtotime($data[$trigger['field']]) + $trigger['days'] * 86400 : 0;
                                        $taskQueue->queueTask($taskRecord->getId(), $recordModel->getId(), $delay);
                                    }

        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

        The method queueScheduledWorkflowTasks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                        } else {
                            foreach ($this->getEligibleWorkflowRecords($workflow) as $recordId) {
                                if (!\App\Record::isExists($recordId)) {
                                    continue;
                                }

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

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

        Avoid using static access to class 'Vtiger_Record_Model' in method 'queueScheduledWorkflowTasks'.
        Open

                                $recordModel = Vtiger_Record_Model::getInstanceById($recordId);

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

                $default_timezone = App\Config::main('default_timezone');

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

                                if (!\App\Record::isExists($recordId)) {

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

                $conditions = \App\Json::decode(App\Purifier::decodeHtml($workflow->test));

        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 'Users' in method 'parseValueForDate'.
        Open

                $admin = Users::getActiveAdminUser();

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

                        } else {
                            $queryGenerator->addCondition($fieldName, $value, $operator, empty($groupId));
                        }

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

                $default_timezone = \App\Config::main('default_timezone');

        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 "less than hours later" 3 times.
        Open

                    'less than hours later' => 'bw',

        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 "in more than" 3 times.
        Open

                    'in more than' => 'g',

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

                        $value = $condition['value'];

        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 "more than hours later" 3 times.
        Open

                    'more than hours later' => 'g',

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

                    'days ago' => 'e',

        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 "Y-m-d H:i:s" 7 times.
        Open

                $currentTimestamp = date('Y-m-d H:i:s');

        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 "more than days ago" 3 times.
        Open

                    'more than days ago' => 'l',

        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 "Y-m-d" 9 times.
        Open

                        $value = date('Y-m-d', strtotime('-' . $days . ' days')) . ',' . date('Y-m-d', strtotime('+1 day'));

        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 "in less than" 3 times.
        Open

                    'in less than' => 'bw',

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

                        $value = date('Y-m-d H:i:s', strtotime('-' . $hours . ' hours')) . ',' . date('Y-m-d H:i:s');

        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 "more than hours before" 3 times.
        Open

                    'more than hours before' => 'l',

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

                    'is today' => 'e',

        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 "less than days ago" 3 times.
        Open

                    'less than days ago' => 'bw',

        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 "less than hours before" 3 times.
        Open

                    'less than hours before' => 'bw',

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

                    'days later' => 'e',

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

                        $value = date('Y-m-d', strtotime('-' . $days . ' days')) . ',' . date('Y-m-d', strtotime('+1 day'));

        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.

        Reference to undeclared property \Users->time_zone
        Open

                $adminTimeZone = $admin->time_zone;

        Reference to undeclared property \Users->time_zone
        Open

                $adminTimeZone = $admin->time_zone;

        Argument 1 (referenceTime) is string but \VTWorkflowManager::getScheduledWorkflows() takes false|object defined at /code/modules/com_vtiger_workflow/VTWorkflowManager.php:163
        Open

                $scheduledWorkflows = $vtWorflowManager->getScheduledWorkflows($currentTimestamp);

        Parameter $queryGenerator has undeclared type \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

            public function addWorkflowConditionsToQueryGenerator(App\QueryGenerator $queryGenerator, $conditions)

        Reference to undeclared property \Workflow->test
        Open

                $conditions = \App\Json::decode(App\Purifier::decodeHtml($workflow->test));

        Class \Workflow was passed to foreach, but it does not extend Traversable. This may be intentional, because some of that class's declared properties are accessible from this context. (This check excludes dynamic properties)
        Open

                foreach ($scheduledWorkflows as &$workflow) {

        Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                            $queryGenerator->addNativeCondition([$queryGenerator->getColumnName('id') => 0]);

        Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                $queryGenerator = new \App\QueryGenerator($moduleName, $this->user->id);

        Call to method getColumnName from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                            $queryGenerator->addNativeCondition([$queryGenerator->getColumnName('id') => 0]);

        Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                return $queryGenerator->createQuery();

        Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                $queryGenerator->setFields(['id']);

        Call to method addCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                            $queryGenerator->addCondition($fieldName, $value, $operator, empty($groupId));

        Reference to undeclared property \Workflow->moduleName
        Open

                $moduleName = $workflow->moduleName;

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

                return $query->column();

        Call to method addRelatedCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
        Open

                            $queryGenerator->addRelatedCondition([

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

        class WorkFlowScheduler

        A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12.
        Open

        <?php

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

             * @var Users

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

            public function getWorkflowQuery(Workflow $workflow)

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

            /**

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

             * Get workflow query.

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

             * Constructor.

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

            public function __construct()

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

                return $queryGenerator->createQuery();

        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->user = Users::getActiveAdminUser();

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

             */

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

                $queryGenerator = new \App\QueryGenerator($moduleName, $this->user->id);

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

                $queryGenerator->setFields(['id']);

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

                $moduleName = $workflow->moduleName;

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

            }

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

            private $user;

        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

            {

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

                    if ($taskRecords) {

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

                }

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

                    'does not equal' => 'n',

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

                    'om' => 'om',

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

                    'after' => 'g',

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

                    'greaterthannow' => 'greaterthannow',

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

                    foreach ($conditions as &$condition) {

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

                        if ('has changed' === $operation || 'not has changed' === $operation || !isset($conditionMapping[$operation])) {

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

                            $value = $this->parseValueForDate($condition);

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

             * @return array

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

            {

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

                    'between' => 'bw',

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

                            continue;

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

                        if (0 != \count($matches)) {

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

                        }

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

                    'less than hours before', 'less than hours later', 'more than hours later', 'more than hours before', 'is today', ];

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

            {

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

                // set the time zone to the admin's time zone, this is needed so that the scheduled workflow will be triggered

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

                $admin = Users::getActiveAdminUser();

        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 ($taskRecords as $taskRecord) {

        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

             * Add workflow conditions to query generator.

        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 = $condition['value'];

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

                        $groupId = $condition['groupid'] ?? 0;

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

                    'is not empty' => 'ny',

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

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

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

                        if ($workflowRecord->getParams('iterationOff')) {

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

            /**

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

                    'ends with' => 'ew',

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

                    'is not' => 'n',

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

                    'less than days ago' => 'bw',

        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

            public function specialDateTimeOperator()

        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 \App\Db\Query

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

                    }

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

                    'less than or equal to' => 'm',

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

                                'relatedModule' => $relatedModule,

        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 Workflow $workflow

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

                return $query->column();

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

            /**

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

             * Queue scheduled workflow tasks.

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

                    $taskRecords = $workflowRecord->getTasks();

        Line exceeds 120 characters; contains 132 characters
        Open

                // at admin's time zone rather than the systems time zone. This is specially needed for Hourly and Daily scheduled workflows

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

                            foreach ($this->getEligibleWorkflowRecords($workflow) as $recordId) {

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

                                    if (true === !empty($taskRecord->getTaskObject()->executeImmediately)) {

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

                                $data = $recordModel->getData();

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

                                        $taskQueue->queueTask($taskRecord->getId(), $recordModel->getId(), $delay);

        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

                    'in more than' => 'g',

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

                    'contains' => 'c',

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

                    'days later' => 'e',

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

                    'is empty' => 'y',

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

                    'days ago' => 'e',

        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

                            $sourceField = $matches[1];

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

                                'value' => $value,

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

                            $relatedFieldName = $matches[3];

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

                            $queryGenerator->addCondition($fieldName, $value, $operator, empty($groupId));

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

                                'sourceField' => $sourceField,

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

                    }

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

             * Special Date functions.

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

            }

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

                // at admin's time zone rather than the systems time zone. This is specially needed for Hourly and Daily scheduled workflows

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

                                    continue;

        Line exceeds 120 characters; contains 128 characters
        Open

                                        $delay = null !== $trigger ? strtotime($data[$trigger['field']]) + $trigger['days'] * 86400 : 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

             * @param array               $conditions

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

                $conditionMapping = [

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

                    'is' => 'e',

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

                    'starts with' => 's',

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

                    'more than hours before' => 'l',

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

                            $queryGenerator->addNativeCondition([$queryGenerator->getColumnName('id') => 0]);

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

             * Get eligible workflow records.

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

                $default_timezone = App\Config::main('default_timezone');

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

                $taskQueue = new VTTaskQueue();

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

                $adminTimeZone = $admin->time_zone;

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

                date_default_timezone_set($default_timezone);

        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

             * @param \App\QueryGenerator $queryGenerator

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

                    'less than hours before' => 'bw',

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

                                'operator' => $operator,

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

                return ['less than days ago', 'more than days ago', 'in less than', 'in more than', 'days ago', 'days later',

        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 = $this->getWorkflowQuery($workflow);

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

                $vtWorflowManager = new VTWorkflowManager();

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

                            foreach ($taskRecords as $taskRecord) {

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

                                        $taskRecord->getTaskObject()->doTask($recordModel);

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

                                        $trigger = $taskRecord->getTaskObject()->trigger;

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

            public function addWorkflowConditionsToQueryGenerator(App\QueryGenerator $queryGenerator, $conditions)

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

                    'equal to' => 'e',

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

                    'greater than or equal to' => 'h',

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

                    'more than days ago' => 'l',

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

                        preg_match('/(\w+) : \((\w+)\) (\w+)/', $condition['fieldname'], $matches);

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

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

                        }

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

                    $vtWorflowManager->updateNexTriggerTime($workflow);

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

                    'smallerthannow' => 'smallerthannow',

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

                        if (\in_array($operation, $this->specialDateTimeOperator())) {

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

                        $value = html_entity_decode($value);

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

                            $relatedModule = $matches[2];

        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

                $currentTimestamp = date('Y-m-d H:i:s');

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

                    $workflowRecord = Settings_Workflows_Record_Model::getInstanceFromWorkflowObject($workflow);

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

                                $taskRecord->getTaskObject()->doTask();

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

                $scheduledWorkflows = 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

                    'less than' => 'l',

        Line exceeds 120 characters; contains 128 characters
        Open

                        if ('has changed' === $operation || 'not has changed' === $operation || !isset($conditionMapping[$operation])) {

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

                            $queryGenerator->addRelatedCondition([

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

                                'relatedField' => $relatedFieldName,

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

             * Function parse the value based on the condition.

        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

                $conditions = \App\Json::decode(App\Purifier::decodeHtml($workflow->test));

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

                $this->addWorkflowConditionsToQueryGenerator($queryGenerator, $conditions);

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

            public function getEligibleWorkflowRecords($workflow): array

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

                date_default_timezone_set($adminTimeZone);

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

                                        $delay = null !== $trigger ? strtotime($data[$trigger['field']]) + $trigger['days'] * 86400 : 0;

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

                    'in less than' => 'bw',

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

                    'less than hours later' => 'bw',

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

                    'more than hours later' => 'g',

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

                ];

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

                        $operator = $conditionMapping[$operation];

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

                        $fieldName = $condition['fieldname'];

        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 'more than days ago':  // less than (current date - givenValue)

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

                    case 'days ago':

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

                    case 'less than hours before':

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

             * User.

        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 \Workflow $workflow

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

                foreach ($scheduledWorkflows as &$workflow) {

        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

                    'does not contain' => 'k',

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

                    'before' => 'l',

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

                        if (!empty($sourceField)) {

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

                                'conditionGroup' => empty($groupId),

        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 parseValueForDate($condition)

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

                $operation = $condition['operation'];

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

                        $days = $condition['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

                        $days = $condition['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

                $scheduledWorkflows = $vtWorflowManager->getScheduledWorkflows($currentTimestamp);

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

                                if (!\App\Record::isExists($recordId)) {

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

                    'greater than' => 'g',

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

                    'nom' => 'nom',

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

                    'is today' => 'e',

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

                if ($conditions) {

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

                        $sourceField = '';

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

                        $operation = $condition['operation'];

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

                        }

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

                // based on the admin users time zone, since query generator expects datetime at user timezone

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

                        $value = date('Y-m-d', strtotime('-' . $days . ' days'));

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

                        $value = date('Y-m-d H:i:s') . ',' . date('Y-m-d H:i:s', strtotime('+' . $hours . ' hours'));

        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

                        $value = date('Y-m-d', strtotime('-' . $days . ' days')) . ',' . date('Y-m-d', strtotime('+1 day'));

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

                    case 'in more than':   // greater than future date(current date + givenValue)

        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

             * @return string

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

                $adminTimeZone = $admin->time_zone;

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

                        $value = date('Y-m-d', strtotime('-1 day')) . ',' . date('Y-m-d', strtotime('+' . $days . ' days'));

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

                    case 'more than hours later':

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

            {

        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

                $value = $condition['value'];

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

                    case 'less than days ago':  //between current date and (currentdate - givenValue)

        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 = date('Y-m-d', strtotime('+' . $days . ' days'));

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

                        $hours = $condition['value'];

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

                        $value = date('Y-m-d H:i:s', strtotime('-' . $hours . ' hours'));

        Line exceeds 120 characters; contains 128 characters
        Open

                    'less than hours before', 'less than hours later', 'more than hours later', 'more than hours before', 'is today', ];

        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 = $condition['value'] - 1;

        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

                }

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

             *

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

                date_default_timezone_set($adminTimeZone);

        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

                        $days = $condition['value'] - 1;

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

                        $days = $condition['value'];

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

                        $value = date('Y-m-d', strtotime('-' . $days . ' days'));

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

                    case 'days later':

        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 'less than hours later':

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

                date_default_timezone_set($default_timezone);

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

                $default_timezone = \App\Config::main('default_timezone');

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

                    case 'is today':

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

                        $value = date('Y-m-d H:i:s', strtotime('-' . $hours . ' hours')) . ',' . date('Y-m-d H:i:s');

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

             * @param array $condition

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

                $admin = Users::getActiveAdminUser();

        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

                        $hours = $condition['value'];

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

                    case 'in less than':   // between current date and future date(current date + givenValue)

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

                        $hours = $condition['value'];

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

                    case 'more than hours before':

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

                        $value = date('Y-m-d');

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

                        $value = date('Y-m-d H:i:s', strtotime('+' . $hours . ' hours'));

        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

                switch ($operation) {

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

                        $days = $condition['value'] + 1;

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

                        $value = date('Y-m-d', strtotime('+' . $days . ' days'));

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

                        $hours = $condition['value'];

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

                        break;

        The variable $default_timezone is not named in camelCase.
        Open

            public function parseValueForDate($condition)
            {
                $value = $condition['value'];
                $operation = $condition['operation'];
        
        

        CamelCaseVariableName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name variables.

        Example

        class ClassName {
            public function doSomething() {
                $data_module = new DataModule();
            }
        }

        Source

        The variable $default_timezone is not named in camelCase.
        Open

            public function parseValueForDate($condition)
            {
                $value = $condition['value'];
                $operation = $condition['operation'];
        
        

        CamelCaseVariableName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name variables.

        Example

        class ClassName {
            public function doSomething() {
                $data_module = new DataModule();
            }
        }

        Source

        The variable $default_timezone is not named in camelCase.
        Open

            public function queueScheduledWorkflowTasks()
            {
                $default_timezone = App\Config::main('default_timezone');
                $vtWorflowManager = new VTWorkflowManager();
                $taskQueue = new VTTaskQueue();

        CamelCaseVariableName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name variables.

        Example

        class ClassName {
            public function doSomething() {
                $data_module = new DataModule();
            }
        }

        Source

        The variable $default_timezone is not named in camelCase.
        Open

            public function queueScheduledWorkflowTasks()
            {
                $default_timezone = App\Config::main('default_timezone');
                $vtWorflowManager = new VTWorkflowManager();
                $taskQueue = new VTTaskQueue();

        CamelCaseVariableName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name variables.

        Example

        class ClassName {
            public function doSomething() {
                $data_module = new DataModule();
            }
        }

        Source

        There are no issues that match your filters.

        Category
        Status