YetiForceCompany/YetiForceCRM

View on GitHub
modules/Calendar/models/RecuringEvents.php

Summary

Maintainability
D
2 days
Test Coverage
F
1%

Function save has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    public function save()
    {
        if (!$this->isNew) {
            switch ($this->typeSaving) {
                case self::UPDATE_ALL_EVENTS:
Severity: Minor
Found in modules/Calendar/models/RecuringEvents.php - About 6 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

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

class Calendar_RecuringEvents_Model extends \App\Base
{
    public $recordModel;
    public $typeSaving;
    public $isNew;

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

    public function delete()
    {
        switch ($this->typeSaving) {
            case self::UPDATE_ALL_EVENTS:
                $records = $this->getRecords($this->recordModel->get('followup'));
Severity: Minor
Found in modules/Calendar/models/RecuringEvents.php - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method save has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function save()
    {
        if (!$this->isNew) {
            switch ($this->typeSaving) {
                case self::UPDATE_ALL_EVENTS:
Severity: Major
Found in modules/Calendar/models/RecuringEvents.php - About 2 hrs to fix

    File RecuringEvents.php has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * Recurring Events Class.
     *
    Severity: Minor
    Found in modules/Calendar/models/RecuringEvents.php - About 2 hrs to fix

      Method delete has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function delete()
          {
              switch ($this->typeSaving) {
                  case self::UPDATE_ALL_EVENTS:
                      $records = $this->getRecords($this->recordModel->get('followup'));
      Severity: Minor
      Found in modules/Calendar/models/RecuringEvents.php - About 1 hr to fix

        Function getDates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getDates($startDateTime, $endDateTime, $recurrenceRule = false)
            {
                if (!$recurrenceRule) {
                    $recurrenceRule = $this->recordModel->get('recurrence');
                }
        Severity: Minor
        Found in modules/Calendar/models/RecuringEvents.php - About 35 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 delete() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
        Open

            public function delete()
            {
                switch ($this->typeSaving) {
                    case self::UPDATE_ALL_EVENTS:
                        $records = $this->getRecords($this->recordModel->get('followup'));

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

            public function save()
            {
                if (!$this->isNew) {
                    switch ($this->typeSaving) {
                        case self::UPDATE_ALL_EVENTS:

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

            public function save()

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

            public function delete()

        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 '307', column '15').
        Open

                $rule = new \Recurr\Rule($recurrenceRule, new \DateTime($startDateTime), new \DateTime($endDateTime));

        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 '349', column '15').
        Open

                return (new App\Db\Query())->from('vtiger_activity')

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

                    $rule = new \Recurr\Rule($record->get('recurrence'));

        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 '307', column '80').
        Open

                $rule = new \Recurr\Rule($recurrenceRule, new \DateTime($startDateTime), new \DateTime($endDateTime));

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

                $data = (new \Recurr\Transformer\ArrayTransformer())->transform($rule);

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

                    $rule->setUntil(new \DateTime($dateStart));

        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 getDates has a boolean flag argument $recurrenceRule, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function getDates($startDateTime, $endDateTime, $recurrenceRule = false)

        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 '333', column '15').
        Open

                return (new App\Db\Query())->from('vtiger_activity')

        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 '307', column '49').
        Open

                $rule = new \Recurr\Rule($recurrenceRule, new \DateTime($startDateTime), new \DateTime($endDateTime));

        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 'Vtiger_Record_Model' in method 'updateNeverEndingEvents'.
        Open

                $record = 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 'Vtiger_Record_Model' in method 'updateOmmitedRecords'.
        Open

                    $record = 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 'Vtiger_Record_Model' in method 'getInstanceFromRequest'.
        Open

                $instance->recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);

        StaticAccess

        Since: 1.4.0

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

        Example

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

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

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

                $record = 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 'Vtiger_Record_Model' in method 'updateNeverEndingEvents'.
        Open

                $cleanInstance = Vtiger_Record_Model::getCleanInstance($record->getModuleName());

        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 {
                    $dates = $this->getDates($this->recordModel->get('date_start') . ' ' . $this->recordModel->get('time_start'), $this->recordModel->get('due_date') . ' ' . $this->recordModel->get('time_end'));
                    unset($dates[0]);
                    if ($dates) {
                        $this->createRecords($dates);

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

                                } else {
                                    Vtiger_Record_Model::getInstanceById($recordId)->delete();
                                }

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

                                } else {
                                    Vtiger_Record_Model::getInstanceById($recordId)->delete();
                                }

        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

        Define a constant instead of duplicating this literal "due_date" 7 times.
        Open

                $dates = $this->getDates($records['date_start'] . ' ' . $records['time_start'], $records['due_date'] . ' ' . $records['time_end']);

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

                    $record->set('due_date', $date['endDate']);

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

                $dates = $this->getDates($records['date_start'] . ' ' . $records['time_start'], $records['due_date'] . ' ' . $records['time_end']);

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

                $dates = $this->getDates($records['date_start'] . ' ' . $records['time_start'], $records['due_date'] . ' ' . $records['time_end']);

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

                    $record->set('time_start', $date['startTime']);

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

                    if ($endingDate > $date['startDate']) {

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

                $dates = $this->getDates($records['date_start'] . ' ' . $records['time_start'], $records['due_date'] . ' ' . $records['time_end']);

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

                    $rule = new \Recurr\Rule($record->get('recurrence'));

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

                $endingDate = date('Y-m-d', strtotime(date('Y-m-d') . ' +1 year'));

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

                                    App\Db::getInstance()->createCommand()->update('vtiger_activity', ['followup' => $recordId, 'reapeat' => 1], ['followup' => $this->templateRecordId])->execute();

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

                            $recordsIds = $this->getRecords($this->recordModel->get('followup'));

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

                    $record->set('time_end', $date['endTime']);

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

                                    App\Db::getInstance()->createCommand()->update('vtiger_activity', ['followup' => $recordId, 'reapeat' => 1], ['followup' => $this->templateRecordId])->execute();

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

                foreach ($this->changes as $fieldName => $value) {

        UnusedLocalVariable

        Since: 0.2

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

        Example

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

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

        Method \Calendar_RecuringEvents_Model::setData is declared to return \App\Base|\Calendar_RecuringEvents_Model|static but has no return value
        Open

            public function setData($values)

        Parameter $records has undeclared type \type
        Open

            public function updateOmmitedRecords($records, $dateStart)

        Suspicious array access to \type
        Open

                                        $this->changes['followup'] = $recordId;

        Parameter $dateStart has undeclared type \type
        Open

            public function updateOmmitedRecords($records, $dateStart)

        Argument 1 (state) is 'Trash' but \Vtiger_Record_Model::changeState() takes \type defined at /code/modules/Vtiger/models/Record.php:1784
        Open

                                Vtiger_Record_Model::getInstanceById($recordId)->changeState('Trash');

        Argument 1 (state) is 'Trash' but \Vtiger_Record_Model::changeState() takes \type defined at /code/modules/Vtiger/models/Record.php:1784
        Open

                            Vtiger_Record_Model::getInstanceById($recordId)->changeState('Trash');

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

                return (new App\Db\Query())->from('vtiger_activity')
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Parameter $values has undeclared type \type
        Open

            public function setChanges($values)

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

                                    App\Db::getInstance()->createCommand()->update('vtiger_activity', ['followup' => $recordId, 'reapeat' => 1], ['followup' => $this->templateRecordId])->execute();
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Argument 1 (time) is \type but \DateTime::__construct() takes ?string
        Open

                    $rule->setUntil(new \DateTime($dateStart));

        Call to method setUntil from undeclared class \Recurr\Rule
        Open

                    $rule->setUntil(new \DateTime($dateStart));
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Argument 1 (haystack) is \type but \strpos() takes string
        Open

                return false === strpos($recurrenceRule, 'COUNT') && false === strpos($recurrenceRule, 'UNTIL');

        Call to method __construct from undeclared class \Recurr\Rule
        Open

                $rule = new \Recurr\Rule($recurrenceRule, new \DateTime($startDateTime), new \DateTime($endDateTime));
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Call to method __construct from undeclared class \Recurr\Rule
        Open

                    $rule = new \Recurr\Rule($record->get('recurrence'));
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Default value for string $recurrenceRule can't be false
        Open

            public function getDates($startDateTime, $endDateTime, $recurrenceRule = false)

        Call to method getString from undeclared class \Recurr\Rule
        Open

                    $record->set('recurrence', $rule->getString());
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Returning type bool but isNeverEndingRule() is declared to return \type
        Open

                return false === strpos($recurrenceRule, 'COUNT') && false === strpos($recurrenceRule, 'UNTIL');

        Call to method __construct from undeclared class \Recurr\Transformer\ArrayTransformer
        Open

                $data = (new \Recurr\Transformer\ArrayTransformer())->transform($rule);
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

        Parameter $recurrenceRule has undeclared type \type
        Open

            public function isNeverEndingRule($recurrenceRule)

        Argument 1 (records) is array{} but \Calendar_RecuringEvents_Model::updateOmmitedRecords() takes \type defined at /code/modules/Calendar/models/RecuringEvents.php:120
        Open

                                $this->updateOmmitedRecords($omittedRecords, $data['date_start']);

        Return type of isNeverEndingRule() is undeclared type \type
        Open

            public function isNeverEndingRule($recurrenceRule)

        Argument 1 (records) is array{} but \Calendar_RecuringEvents_Model::updateOmmitedRecords() takes \type defined at /code/modules/Calendar/models/RecuringEvents.php:120
        Open

                                        $this->updateOmmitedRecords($omittedRecords, $data['date_start']);

        Call to method transform from undeclared class \Recurr\Transformer\ArrayTransformer
        Open

                $data = (new \Recurr\Transformer\ArrayTransformer())->transform($rule);
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

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

                return (new App\Db\Query())->from('vtiger_activity')
        Severity: Critical
        Found in modules/Calendar/models/RecuringEvents.php by phan

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

        class Calendar_RecuringEvents_Model extends \App\Base

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

            public function getRecords($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

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

            public function getLastRecord($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 Calendar_RecuringEvents_Model is not named in CamelCase.
        Open

        class Calendar_RecuringEvents_Model extends \App\Base
        {
            public $recordModel;
            public $typeSaving;
            public $isNew;

        CamelCaseClassName

        Since: 0.2

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

        Example

        class class_name {
        }

        Source

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

                }

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

                    }

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

            public static function getInstance()

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

             */

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

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

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

                $dates = $this->getDates($records['date_start'] . ' ' . $records['time_start'], $records['due_date'] . ' ' . $records['time_end']);

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

                    }

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

                }

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

             *

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

            /**

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

            /**

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

             *

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

            public $isNew;

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

                $cleanInstance = Vtiger_Record_Model::getCleanInstance($record->getModuleName());

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

            public static function getInstanceFromRequest(App\Request $request)

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

                if (!$instance->isNew) {

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

                        $instance->typeSaving = self::UPDATE_THIS_EVENT;

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

             * Function to set data to record model.

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

            public $typeSaving;

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

            public $templateRecordId;

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

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

            const UPDATE_FUTURE_EVENTS = 3;

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

             * Function to create new records in never ending events. Function uses only by cron.

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

                $cleanInstance->setData($record->getData());

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

                $instance->recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);

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

                return 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

                foreach ($dates as $date) {

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

                    if ($endingDate > $date['startDate']) {

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

             * Function to get instance of class.

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

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

            {

        Line exceeds 120 characters; contains 139 characters
        Open

                $dates = $this->getDates($records['date_start'] . ' ' . $records['time_start'], $records['due_date'] . ' ' . $records['time_end']);

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

                        $this->createRecords([$date]);

        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

                    $instance->typeSaving = $request->getInteger('typeSaving');

        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 (!$this->isNew) {

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

                            $itemNumber = 0;

        Line exceeds 120 characters; contains 130 characters
        Open

                                    if (!($this->recordModel->getPreviousValue('recurrence') === $this->recordModel->get('recurrence'))) {

        Line exceeds 120 characters; contains 203 characters
        Open

                    $dates = $this->getDates($this->recordModel->get('date_start') . ' ' . $this->recordModel->get('time_start'), $this->recordModel->get('due_date') . ' ' . $this->recordModel->get('time_end'));

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

            public $recordModel;

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

            const UPDATE_THIS_EVENT = 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

                unset($dates[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

            public function setChanges($values)

        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 updateRecord($recordId, $dates)

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

                            $dates = [];

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

                                }

        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

                            $omittedRecords = [];

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

                                if ($skip && $data['date_start'] >= $this->recordModel->get('date_start')) {

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

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

                    unset($dates[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

                $record->set('time_start', $dates['startTime']);

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

                $record->set('due_date', $dates['endDate']);

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

                                if (isset($dates[$itemNumber])) {

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

                                    Vtiger_Record_Model::getInstanceById($recordId)->delete();

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

                        case self::UPDATE_FUTURE_EVENTS:

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

                                    }

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

                } else {

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

                            foreach ($recordsIds as $recordId => $data) {

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

             * Function to get dates.

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

             * @param string $endDateTime

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

                $rule = new \Recurr\Rule($recurrenceRule, new \DateTime($startDateTime), new \DateTime($endDateTime));

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

                    ->orderBy(['date_start' => SORT_DESC])

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

             * Function to get empty instance.

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

                $endingDate = date('Y-m-d', strtotime(date('Y-m-d') . ' +1 year'));

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

            }

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

                $moduleName = $request->getModule();

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

                    $instance->templateRecordId = $request->getInteger('record');

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

                    if (empty($instance->typeSaving)) {

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

                    $record->set('date_start', $date['startDate']);

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

                    $record->set('time_start', $date['startTime']);

        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 type $dateStart

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

                            $recordsIds = $this->getRecords($this->recordModel->get('followup'));

        Line exceeds 120 characters; contains 147 characters
        Open

                                    $dates = $this->getDates($data['date_start'] . ' ' . $data['time_start'], $data['due_date'] . ' ' . $data['time_end']);

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

                                }

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

                            break;

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

                            $recordsIds = $this->getRecords($this->recordModel->get('followup'));

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

                            $skip = true;

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

            /**

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

                            }

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

                        if ($this->templateRecordId === $this->recordModel->get('followup')) {

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

             * Check if recurrence rule is never ending.

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

             * @param type $recurrenceRule

        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 false === strpos($recurrenceRule, 'COUNT') && false === strpos($recurrenceRule, 'UNTIL');

        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 array

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

            public function getLastRecord($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

                return (new App\Db\Query())->from('vtiger_activity')

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

                    ->where(['followup' => $id, 'deleted' => 0, 'reapeat' => 1])

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

            const UPDATE_ALL_EVENTS = 1;

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

            public function updateNeverEndingEvents($recordId)

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

                $this->recordModel = $cleanInstance;

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

                $records = $this->getLastRecord($recordId);

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

             * @param \App\Request $request

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

             */

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

                $instance->isNew = $request->isEmpty('record');

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

                    $record->set('time_end', $date['endTime']);

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

                    $record->save();

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

             * @param type $records

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

            {

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

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

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

                            if ($dates) {

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

                        $omittedRecords = [];

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

                                $skip = false;

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

                            }

        Line exceeds 120 characters; contains 189 characters
        Open

                                    App\Db::getInstance()->createCommand()->update('vtiger_activity', ['followup' => $recordId, 'reapeat' => 1], ['followup' => $this->templateRecordId])->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

                if ($isNeverEnding) {

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

                    ->all();

        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 int $recordId

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

             * @return Calendar_RecuringEvents_Model

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

                $this->recordModel->setData($values);

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

                }

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

                    $rule->setUntil(new \DateTime($dateStart));

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

             */

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

                                    ++$itemNumber;

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

                                    $this->updateRecord($recordId, $dates[$itemNumber]);

        Line exceeds 120 characters; contains 151 characters
        Open

                                        $dates = $this->getDates($data['date_start'] . ' ' . $data['time_start'], $data['due_date'] . ' ' . $data['time_end']);

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

                                    unset($dates[$itemNumber]);

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

                        $this->createRecords($dates);

        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 remove records.

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

             */

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

                        $records = $this->getRecords($this->recordModel->get('followup'));

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

            public function isNeverEndingRule($recurrenceRule)

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

                if (!$recurrenceRule) {

        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 create new records.

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

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

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

                            $dates = reset($recordsIds);

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

                                    $this->updateRecord($recordId, $dates[$itemNumber]);

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

                                    unset($dates[$itemNumber]);

        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

                        break;

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

                        foreach ($recordsIds as $recordId => $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

                        }

        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

            public function getDates($startDateTime, $endDateTime, $recurrenceRule = false)

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

                        'endDate' => $date->getEnd()->format('Y-m-d'),

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

             * @param array $values

        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 set changes which user modified.

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

                    $record->set($fieldName, $this->recordModel->get($fieldName));

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

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

                                    $skip = false;

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

                            Vtiger_Record_Model::getInstanceById($recordId)->changeState('Trash');

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

                                    break;

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

                }

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

            /**

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

                    }

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

                    ->limit(1)

        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

                $this->changes = $values;

        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 ($this->changes as $fieldName => $value) {

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

                $record->set('date_start', $dates['startDate']);

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

            /**

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

             * Save records.

        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

                            foreach ($recordsIds as $recordId => $data) {

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

                                if (0 === $itemNumber) {

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

                                if ($recordId === $this->templateRecordId) {

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

                                    unset($dates[$itemNumber]);

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

                                    unset($dates[$itemNumber]);

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

                                ++$itemNumber;

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

                            $itemNumber = 0;

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

                                        $this->recordModel->set('followup', $recordId);

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

                            break;

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

            }

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

             *

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

                }

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

                $data = (new \Recurr\Transformer\ArrayTransformer())->transform($rule);

        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

            {

        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 last record in series.

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

            public function createRecords($dates)

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

                foreach ($dates as $date) {

        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

                                    continue;

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

                                    if (!($this->recordModel->getPreviousValue('recurrence') === $this->recordModel->get('recurrence'))) {

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

                                        $this->changes['followup'] = $recordId;

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

                                if (isset($dates[$itemNumber])) {

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

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

                    case self::UPDATE_ALL_EVENTS:

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

                        foreach ($records as $recordId => $data) {

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

                    case self::UPDATE_FUTURE_EVENTS:

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

                        $recordsIds = $this->getRecords($this->recordModel->get('followup'));

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

                    case self::UPDATE_THIS_EVENT:

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

                                    App\Db::getInstance()->createCommand()->update('vtiger_activity', ['followup' => $recordId, 'reapeat' => 1], ['followup' => $this->templateRecordId])->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

                        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

                    ->orderBy(['date_start' => SORT_ASC])

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

                    ->indexBy('activityid')

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

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

                    $dates = $this->getDates($this->recordModel->get('date_start') . ' ' . $this->recordModel->get('time_start'), $this->recordModel->get('due_date') . ' ' . $this->recordModel->get('time_end'));

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

             *

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

                    ->one();

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

            public function setData($values)

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

             * @param type $values

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

                    $rule = new \Recurr\Rule($record->get('recurrence'));

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

             * @param int   $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

                                $this->createRecords($dates);

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

                                        $dates = $this->getDates($data['date_start'] . ' ' . $data['time_start'], $data['due_date'] . ' ' . $data['time_end']);

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

                                if ($skip) {

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

                                ++$itemNumber;

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

        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

                        }

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

                            $recordsIds = $this->getRecords($this->recordModel->get('followup'));

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

                $dates = [];

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

                        'startDate' => $date->getStart()->format('Y-m-d'),

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

                        'startTime' => $date->getStart()->format('H:i:s'),

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

             * Function to get related records.

        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 getRecords($id)

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

                    $record->set('due_date', $date['endDate']);

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

                    $record = clone $this->recordModel;

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

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

                $record->set('time_end', $dates['endTime']);

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

             * Update ommited records, change recuring rule for each records.

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

                    switch ($this->typeSaving) {

        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 self::UPDATE_ALL_EVENTS:

        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

                                    continue;

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

                            }

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

                                    Vtiger_Record_Model::getInstanceById($recordId)->delete();

        Line exceeds 120 characters; contains 165 characters
        Open

                            $dates = $this->getDates($dates['date_start'] . ' ' . $dates['time_start'], $dates['due_date'] . ' ' . $dates['time_end'], $dates['recurrence']);

        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->updateOmmitedRecords($omittedRecords, $data['date_start']);

        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 ($skip && $data['date_start'] >= $this->recordModel->get('date_start')) {

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

                            }

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

                                $omittedRecords[] = $recordId;

        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

                    default:

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

                        }

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

                            $skip = true;

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

             *

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

             * @return type

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

             *

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

            }

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

             * @return array

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

                $isNeverEnding = $this->isNeverEndingRule($recurrenceRule);

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

                        'endTime' => $date->getEnd()->format('H:i:s'),

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

                    $endingDate = date('Y-m-d', strtotime(date('Y-m-d', strtotime($startDateTime)) . ' +1 year'));

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

                    if ($isNeverEnding && $date->getStart()->format('Y-m-d') > $endingDate) {

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

             * @param array $dates

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

                foreach ($records as $recordId) {

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

                    $record->set('recurrence', $rule->getString());

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

                }

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

                                    $dates = $this->getDates($data['date_start'] . ' ' . $data['time_start'], $data['due_date'] . ' ' . $data['time_end']);

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

                            foreach ($recordsIds as $recordId => $data) {

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

                                        $this->updateOmmitedRecords($omittedRecords, $data['date_start']);

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

                                    ++$itemNumber;

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

                            if ($dates) {

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

                            break;

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

                    if ($dates) {

        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 !== $this->templateRecordId) {

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

                                if ($data['date_start'] >= $this->recordModel->get('date_start')) {

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

                foreach ($data as $date) {

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

                return $dates;

        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

             */

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

            public function updateOmmitedRecords($records, $dateStart)

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

                    $record->save();

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

                            $dates = $this->getDates($dates['date_start'] . ' ' . $dates['time_start'], $dates['due_date'] . ' ' . $dates['time_end'], $dates['recurrence']);

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

                                    $omittedRecords[] = $recordId;

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

                switch ($this->typeSaving) {

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

                            }

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

                        break;

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

             * @param string $startDateTime

        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 (new App\Db\Query())->from('vtiger_activity')

        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

                    $dates[] = [

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

                    ];

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

                    ->where(['followup' => $id, 'deleted' => 0, 'reapeat' => 1])

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

                    ->indexBy('activityid')

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

                                Vtiger_Record_Model::getInstanceById($recordId)->changeState('Trash');

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

                        $skip = true;

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

                            if ($skip) {

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

             * @param string $recurrenceRule

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

                    $recurrenceRule = $this->recordModel->get('recurrence');

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

        class Calendar_RecuringEvents_Model extends \App\Base

        There are no issues that match your filters.

        Category
        Status