YetiForceCompany/YetiForceCRM

View on GitHub
modules/API/models/CalDAV.php

Summary

Maintainability
D
2 days
Test Coverage
F
52%

Function davSync has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    public function davSync(): int
    {
        $create = $updates = 0;
        foreach ($this->davUsers as $userId => $user) {
            $this->calendarId = $user->get('calendarsid');
Severity: Minor
Found in modules/API/models/CalDAV.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

File CalDAV.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Api CalDAV Model Class.
 *
Severity: Minor
Found in modules/API/models/CalDAV.php - About 2 hrs to fix

    Function recordSync has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function recordSync(): int
        {
            \App\Log::trace('Start', __METHOD__);
            $query = (new \App\Db\Query())->select([
                'dav_calendarobjects.*',
    Severity: Minor
    Found in modules/API/models/CalDAV.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 recordSync has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function recordSync(): int
        {
            \App\Log::trace('Start', __METHOD__);
            $query = (new \App\Db\Query())->select([
                'dav_calendarobjects.*',
    Severity: Minor
    Found in modules/API/models/CalDAV.php - About 1 hr to fix

      Method davSync has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function davSync(): int
          {
              $create = $updates = 0;
              foreach ($this->davUsers as $userId => $user) {
                  $this->calendarId = $user->get('calendarsid');
      Severity: Minor
      Found in modules/API/models/CalDAV.php - About 1 hr to fix

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

            public function recordCreate($cal)
            {
                \App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
                $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
                foreach ($calendar->getRecordInstance() as $recordModel) {
        Severity: Minor
        Found in modules/API/models/CalDAV.php - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

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

            public function recordUpdate(Vtiger_Record_Model $record, $cal)
            {
                \App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
                $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
                foreach ($calendar->getRecordInstance() as $recordModel) {
        Severity: Minor
        Found in modules/API/models/CalDAV.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 recordCreate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function recordCreate($cal)
            {
                \App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
                $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
                foreach ($calendar->getRecordInstance() as $recordModel) {
        Severity: Minor
        Found in modules/API/models/CalDAV.php - About 1 hr to fix

          Method davCreate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function davCreate()
              {
                  \App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
                  $instance = \App\Integrations\Dav\Calendar::createEmptyInstance();
                  $instance->loadFromArray($this->record);
          Severity: Minor
          Found in modules/API/models/CalDAV.php - About 1 hr to fix

            Method recordUpdate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function recordUpdate(Vtiger_Record_Model $record, $cal)
                {
                    \App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
                    $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
                    foreach ($calendar->getRecordInstance() as $recordModel) {
            Severity: Minor
            Found in modules/API/models/CalDAV.php - About 1 hr to fix

              Function toDelete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function toDelete($cal)
                  {
                      if ('' === $cal['assigned_user_id'] || 0 !== (int) $cal['deleted']) {
                          return true;
                      }
              Severity: Minor
              Found in modules/API/models/CalDAV.php - About 45 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 davSync() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
              Open

                  public function davSync(): int
                  {
                      $create = $updates = 0;
                      foreach ($this->davUsers as $userId => $user) {
                          $this->calendarId = $user->get('calendarsid');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                  protected function toDelete($cal)
                  {
                      if ('' === $cal['assigned_user_id'] || 0 !== (int) $cal['deleted']) {
                          return true;
                      }
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                  public function davSync(): int
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

              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 recordSync(): int
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                      return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                      $query = (new \App\Db\Query())->select([
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                      $queryGenerator = new \App\QueryGenerator('Calendar');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

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

              Avoid using static access to class '\App\Log' in method 'davCreate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'davCreate'.
              Open

                      \App\Integrations\Dav\Calendar::addChange($this->calendarId, $calUri, 1);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'dav2Crm'.
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                                  } else {
                                      ++$skipped;
                                  }
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordCreate'.
              Open

                                      \App\Log::info(__METHOD__ . ' | End exclusion');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'davCreate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                              } else {
                                  ++$skipped;
                              }
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Fields\SharedOwner' in method 'toDelete'.
              Open

                              $isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($userId, \App\Fields\SharedOwner::getById($cal['id']));
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'recordUpdate'.
              Open

                      $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordUpdate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordUpdate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class '\App\Fields\SharedOwner' in method 'toDelete'.
              Open

                              $shownerIds = \App\Fields\SharedOwner::getById($cal['id']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                              $exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_TO_DAV');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'dav2Crm'.
              Open

                      \App\Log::trace(__METHOD__ . ' | Start');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\User' in method 'davSync'.
              Open

                                  App\User::setCurrentUserId($orgUserId);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'recordCreate'.
              Open

                      $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'davUpdate'.
              Open

                      $instance = \App\Integrations\Dav\Calendar::loadFromDav($dav['calendardata']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'davUpdate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordCreate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                          $exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordUpdate'.
              Open

                                      \App\Log::info(__METHOD__ . ' | End exclusion');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\User' in method 'davSync'.
              Open

                                  $orgUserId = App\User::getCurrentUserId();
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'davCreate'.
              Open

                      $instance = \App\Integrations\Dav\Calendar::createEmptyInstance();
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                          } else {
                              if (strtotime($row['modifiedtime']) < $row['lastmodified']) { // Updating
                                  if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {
                                      ++$updates;
                                  } else {
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordSync'.
              Open

                      \App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\User' in method 'davSync'.
              Open

                                  App\User::setCurrentUserId($userId);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                                  if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                          $exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordCreate'.
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'davSync'.
              Open

                      \App\Log::trace("Calendar end - CRM >> DAV | create: $create | updates: $updates", __METHOD__);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'davUpdate'.
              Open

                      \App\Integrations\Dav\Calendar::addChange($this->calendarId, $dav['uri'], 2);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Integrations\Dav\Calendar' in method 'recordSync'.
              Open

                              \App\Integrations\Dav\Calendar::delete($row);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'crm2Dav'.
              Open

                      \App\Log::trace(__METHOD__ . ' | Start');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'crm2Dav'.
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              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\Log' in method 'recordSync'.
              Open

                      \App\Log::trace('Start', __METHOD__);
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                      $queryGenerator->setCustomColumn(['vtiger_crmentity.deleted']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                                  } elseif (strtotime($this->record['modifiedtime']) > $event['lastmodified']) { // Updating
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Define a constant instead of duplicating this literal "crmid" 11 times.
              Open

                          'crmid' => $this->record['id'],
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                          'calendarid' => $this->calendarId,
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                          ->leftJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = dav_calendarobjects.crmid')
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                      \App\Db::getInstance()->createCommand()->insert('dav_calendarobjects', [
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                          'calendardata' => $calendarData,
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                      $queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

                      $queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Call to method setCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
              Open

                                  App\User::setCurrentUserId($orgUserId);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method serialize from undeclared class \Sabre\VObject\Component\VCalendar
              Open

                      $calendarData = $calendar->serialize();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      $query = $queryGenerator->createQuery();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method info from undeclared class \App\Log
              Open

                                      \App\Log::info(__METHOD__ . ' | End exclusion');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Assigning false to property but \API_CalDAV_Model->calendarId is int
              Open

                  public $calendarId = false;
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phan

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

                      $queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Reference to instance property name from undeclared class \Sabre\VObject\Component
              Open

                      if ('VEVENT' === (string) $component->name) {
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Reference to instance property name from undeclared class \Sabre\VObject\Component
              Open

                      if ('VEVENT' === (string) $component->name) {
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method setCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
              Open

                                  App\User::setCurrentUserId($userId);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      \App\Db::getInstance()->createCommand()->update('dav_calendarobjects', [
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method info from undeclared class \App\Log
              Open

                                      \App\Log::info(__METHOD__ . ' | End exclusion');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Reference to instance property permissions from undeclared class \App\QueryGenerator
              Open

                      $queryGenerator->permissions = false;
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phan

              Reference to instance property UID from undeclared class \Sabre\VObject\Component
              Open

                      $uid = (string) $component->UID;
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace('Start', __METHOD__);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      $queryGenerator = new \App\QueryGenerator('Calendar');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                          $dbCommand = \App\Db::getInstance()->createCommand();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      App\Db::getInstance()->createCommand()->update('vtiger_activity', [
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | Start');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                          $dbCommand = \App\Db::getInstance()->createCommand();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      $queryGenerator->setCustomColumn(['vtiger_crmentity.deleted']);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace("Calendar end - CRM >> DAV | create: $create | updates: $updates", __METHOD__);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method serialize from undeclared class \Sabre\VObject\Component\VCalendar
              Open

                      $calendarData = $calendar->serialize();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | End');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Assigning false to property but \API_CalDAV_Model->record is array
              Open

                  public $record = false;
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phan

              Call to method trace from undeclared class \App\Log
              Open

                      \App\Log::trace(__METHOD__ . ' | Start');
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      $query = (new \App\Db\Query())->select([
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

              Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
              Open

                                  $orgUserId = App\User::getCurrentUserId();
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                      \App\Db::getInstance()->createCommand()->insert('dav_calendarobjects', [
              Severity: Critical
              Found in modules/API/models/CalDAV.php by phan

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

                          case 'PLL_OWNER_PERSON_GROUP':
                              $shownerIds = \App\Fields\SharedOwner::getById($cal['id']);
                              $isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($cal['assigned_user_id'], $this->user->get('groups')) || \in_array($userId, $shownerIds) || \count(array_intersect($shownerIds, $this->user->get('groups'))) > 0;
                              break;
              Severity: Major
              Found in modules/API/models/CalDAV.php and 1 other location - About 1 hr to fix
              modules/API/models/CardDAV.php on lines 165..168

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 113.

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

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

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

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

              Refactorings

              Further Reading

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

              class API_CalDAV_Model

              The class API_CalDAV_Model is not named in CamelCase.
              Open

              class API_CalDAV_Model
              {
                  /**
                   * Prod id.
                   *
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              CamelCaseClassName

              Since: 0.2

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

              Example

              class class_name {
              }

              Source

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

                      $i = 0;
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

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

                      $i = 0;
              Severity: Minor
              Found in modules/API/models/CalDAV.php by phpmd

              ShortVariable

              Since: 0.2

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

              Example

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

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

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ->where(['calendarid' => $this->calendarId]);

              Spaces must be used for alignment; tabs are not allowed
              Open

                              } else {

              Spaces must be used for alignment; tabs are not allowed
              Open

                      \App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * Record create.

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $dbCommand->update('dav_calendarobjects', [

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $dbCommand->update('vtiger_crmentity', [

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $calendar->recordSaveAttendee($recordModel);

              Spaces must be used for alignment; tabs are not allowed
              Open

                      return true;

              Spaces must be used for alignment; tabs are not allowed
              Open

                  /**

              Spaces must be used for alignment; tabs are not allowed
              Open

                   */

              Spaces must be used for alignment; tabs are not allowed
              Open

                      $skipped = $create = $deletes = $updates = 0;

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                      $dataReader->close();

              Spaces must be used for alignment; tabs are not allowed
              Open

                                      \App\Log::info(__METHOD__ . ' | End exclusion');

              Spaces must be used for alignment; tabs are not allowed
              Open

                              }

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $recordModel->save();

              Spaces must be used for alignment; tabs are not allowed
              Open

                          )->execute();

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * Record update.

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ->leftJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = dav_calendarobjects.crmid')

              Spaces must be used for alignment; tabs are not allowed
              Open

                              \App\Integrations\Dav\Calendar::delete($row);

              Spaces must be used for alignment; tabs are not allowed
              Open

                          } else {

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                  {

              Spaces must be used for alignment; tabs are not allowed
              Open

                      $dataReader = $query->createCommand()->query();

              Spaces must be used for alignment; tabs are not allowed
              Open

                      }

              Spaces must be used for alignment; tabs are not allowed
              Open

                   */

              Spaces must be used for alignment; tabs are not allowed
              Open

                          if (!$row['crmid']) { //Creating

              Spaces must be used for alignment; tabs are not allowed
              Open

                  public function recordCreate($cal)

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ], ['crmid' => $recordModel->getId()]

              Spaces must be used for alignment; tabs are not allowed
              Open

                          }

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                          )->execute();

              Spaces must be used for alignment; tabs are not allowed
              Open

                      \App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @return bool

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $dbCommand->update('vtiger_crmentity', [

              Spaces must be used for alignment; tabs are not allowed
              Open

                              'crmid' => $recordModel->getId(),

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  ++$create;

              Spaces must be used for alignment; tabs are not allowed
              Open

                              }

              Spaces must be used for alignment; tabs are not allowed
              Open

                      return $create + $updates + $deletes;

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @param array               $cal

              Spaces must be used for alignment; tabs are not allowed
              Open

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

              Spaces must be used for alignment; tabs are not allowed
              Open

                          }

              Spaces must be used for alignment; tabs are not allowed
              Open

                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                      $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);

              Spaces must be used for alignment; tabs are not allowed
              Open

                              }

              Spaces must be used for alignment; tabs are not allowed
              Open

                          'vtiger_crmentity.modifiedtime', 'vtiger_crmentity.setype',    'assigned_user_id' => 'vtiger_crmentity.smownerid',

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ->leftJoin('vtiger_activity', 'vtiger_crmentity.crmid = vtiger_activity.activityid')

              Spaces must be used for alignment; tabs are not allowed
              Open

                                      \App\Log::info(__METHOD__ . ' | End exclusion');

              Spaces must be used for alignment; tabs are not allowed
              Open

                          )->execute();

              Spaces must be used for alignment; tabs are not allowed
              Open

                      ])->from('dav_calendarobjects')

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @param array $cal

              Spaces must be used for alignment; tabs are not allowed
              Open

                          if (\is_array($exclusion)) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                              'modifiedtime' => date('Y-m-d H:i:s', $cal['lastmodified']),

              Spaces must be used for alignment; tabs are not allowed
              Open

                          } elseif ($this->toDelete(array_merge($row, ['id' => $row['crmid']]))) { // Deleting

              Spaces must be used for alignment; tabs are not allowed
              Open

                              ++$deletes;

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  } else {

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                                      return false;

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $recordModel->save();

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @return bool

              Spaces must be used for alignment; tabs are not allowed
              Open

                      foreach ($calendar->getRecordInstance() as $recordModel) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ], ['id' => $cal['id']]

              Spaces must be used for alignment; tabs are not allowed
              Open

                      \App\Log::trace(__METHOD__ . ' | End');

              Spaces must be used for alignment; tabs are not allowed
              Open

                      $calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $dbCommand = \App\Db::getInstance()->createCommand();

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $dbCommand->update('dav_calendarobjects', [

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ], ['id' => $cal['id']]

              Spaces must be used for alignment; tabs are not allowed
              Open

                              if ($this->recordCreate($row)) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                              if (strtotime($row['modifiedtime']) < $row['lastmodified']) { // Updating

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $recordModel->set('assigned_user_id', $this->user->get('id'));

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');

              Spaces must be used for alignment; tabs are not allowed
              Open

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

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $dbCommand = \App\Db::getInstance()->createCommand();

              Spaces must be used for alignment; tabs are not allowed
              Open

                              'crmid' => $recordModel->getId(),

              Spaces must be used for alignment; tabs are not allowed
              Open

                      }

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @param Vtiger_Record_Model $record

              Spaces must be used for alignment; tabs are not allowed
              Open

                      foreach ($calendar->getRecordInstance() as $recordModel) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                  /**

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');

              Spaces must be used for alignment; tabs are not allowed
              Open

                  {

              Spaces must be used for alignment; tabs are not allowed
              Open

                                      return false;

              Spaces must be used for alignment; tabs are not allowed
              Open

                      \App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);

              Spaces must be used for alignment; tabs are not allowed
              Open

                          }

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  if ($recordModel->get($key) == $value) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                          'vtiger_crmentity.crmid', 'vtiger_crmentity.deleted', 'vtiger_activity.visibility'

              Spaces must be used for alignment; tabs are not allowed
              Open

                                      ++$updates;

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  if ($recordModel->get($key) == $value) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                                      ++$skipped;

              Spaces must be used for alignment; tabs are not allowed
              Open

                              }

              Spaces must be used for alignment; tabs are not allowed
              Open

                          if (false !== $exclusion) {

              Spaces must be used for alignment; tabs are not allowed
              Open

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

              Spaces must be used for alignment; tabs are not allowed
              Open

                                  ++$skipped;

              Spaces must be used for alignment; tabs are not allowed
              Open

                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                  public function recordUpdate(Vtiger_Record_Model $record, $cal)

              Spaces must be used for alignment; tabs are not allowed
              Open

                   */

              Spaces must be used for alignment; tabs are not allowed
              Open

                  protected function recordMarkComplete()

              Spaces must be used for alignment; tabs are not allowed
              Open

                  protected function toDelete($cal)

              Spaces must be used for alignment; tabs are not allowed
              Open

                      if (!$isPermitted && 'Public' !== $cal['visibility']) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                              'modifiedtime' => date('Y-m-d H:i:s', $cal['lastmodified']),

              Spaces must be used for alignment; tabs are not allowed
              Open

                          ], ['crmid' => $recordModel->getId()]

              Spaces must be used for alignment; tabs are not allowed
              Open

                      }

              Spaces must be used for alignment; tabs are not allowed
              Open

                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                  public function getDavDetail()

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                      }

              Spaces must be used for alignment; tabs are not allowed
              Open

                  {

              Spaces must be used for alignment; tabs are not allowed
              Open

                      }

              Spaces must be used for alignment; tabs are not allowed
              Open

                          )->execute();

              Spaces must be used for alignment; tabs are not allowed
              Open

                      return true;

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @return array|bool

              Spaces must be used for alignment; tabs are not allowed
              Open

                   */

              Spaces must be used for alignment; tabs are not allowed
              Open

                          default:

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * Record mark complete.

              Spaces must be used for alignment; tabs are not allowed
              Open

                   */

              Spaces must be used for alignment; tabs are not allowed
              Open

                      $userId = (int) $this->user->getId();

              Spaces must be used for alignment; tabs are not allowed
              Open

                          case 'PLL_OWNER_PERSON_GROUP':

              Spaces must be used for alignment; tabs are not allowed
              Open

                      App\Db::getInstance()->createCommand()->update('vtiger_activity', [

              Spaces must be used for alignment; tabs are not allowed
              Open

                              $isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($userId, \App\Fields\SharedOwner::getById($cal['id']));

              Spaces must be used for alignment; tabs are not allowed
              Open

                  {

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * To delete.

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @param array $cal

              Spaces must be used for alignment; tabs are not allowed
              Open

                              break;

              Spaces must be used for alignment; tabs are not allowed
              Open

                          return true;

              Spaces must be used for alignment; tabs are not allowed
              Open

                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                      if ('' === $cal['assigned_user_id'] || 0 !== (int) $cal['deleted']) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                          return true;

              Spaces must be used for alignment; tabs are not allowed
              Open

                          case 'PLL_OWNER':

              Spaces must be used for alignment; tabs are not allowed
              Open

                              $isPermitted = (int) $cal['assigned_user_id'] === $userId;

              Spaces must be used for alignment; tabs are not allowed
              Open

                      \App\Log::trace(__METHOD__ . ' | End');

              Spaces must be used for alignment; tabs are not allowed
              Open

                  /**

              Spaces must be used for alignment; tabs are not allowed
              Open

                      return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();

              Spaces must be used for alignment; tabs are not allowed
              Open

                      ], ['activityid' => $this->record['id']]

              Spaces must be used for alignment; tabs are not allowed
              Open

                  /**

              Spaces must be used for alignment; tabs are not allowed
              Open

                      switch ($this->user->get('sync_caldav')) {

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                              $shownerIds = \App\Fields\SharedOwner::getById($cal['id']);

              Spaces must be used for alignment; tabs are not allowed
              Open

                      }

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * Get dav detail.

              Spaces must be used for alignment; tabs are not allowed
              Open

                   *

              Spaces must be used for alignment; tabs are not allowed
              Open

                   * @return bool

              Spaces must be used for alignment; tabs are not allowed
              Open

                              break;

              Spaces must be used for alignment; tabs are not allowed
              Open

                              $isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($cal['assigned_user_id'], $this->user->get('groups')) || \in_array($userId, $shownerIds) || \count(array_intersect($shownerIds, $this->user->get('groups'))) > 0;

              Spaces must be used for alignment; tabs are not allowed
              Open

                      return false;

              Spaces must be used for alignment; tabs are not allowed
              Open

                          $calendar->recordSaveAttendee($recordModel);

              Spaces must be used for alignment; tabs are not allowed
              Open

                  }

              Spaces must be used for alignment; tabs are not allowed
              Open

                  {

              Spaces must be used for alignment; tabs are not allowed
              Open

                              break;

              Spaces must be used for alignment; tabs are not allowed
              Open

                  /**

              Spaces must be used for alignment; tabs are not allowed
              Open

                          'dav_status' => 0,

              Spaces must be used for alignment; tabs are not allowed
              Open

                      )->execute();

              Spaces must be used for alignment; tabs are not allowed
              Open

                          case 'PLL_OWNER_PERSON':

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

                   * Calendar name.

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

                   * @var string

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

                   * @var string

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

                  const PRODID = 'YetiForce';

              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

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

                  const CALENDAR_NAME = 'YFCalendar';

              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 $record = false;

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

                      $query = $queryGenerator->createQuery();

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

                      $i = 0;

              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

                          'calendarid' => $this->calendarId,

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

                          'crmid' => $this->record['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

                  public $user = false;

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

                  public function davSync(): int

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

                      $create = $updates = 0;

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

                          $this->calendarId = $user->get('calendarsid');

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

                                      // Creating

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

                  }

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

                      \App\Integrations\Dav\Calendar::addChange($this->calendarId, $calUri, 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

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

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

                      $calendar = $instance->getVCalendar();

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

                      $uid = (string) $component->UID;

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

                      if ('VEVENT' === (string) $component->name) {

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

                      $calendarData = $calendar->serialize();

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

                          'lastmodified' => strtotime($this->record['modifiedtime']),

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

                   * @var 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

                  protected static $cache = [];

              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

                          $this->user = $user;

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

                                      $this->davUpdate($event);

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

                  public function davCreate()

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

                      \App\Db::getInstance()->createCommand()->insert('dav_calendarobjects', [

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

                      ])->execute();

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

                   * @var string

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

                  /**

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

                   * Calendar id.

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

                      $queryGenerator->permissions = false;

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

                          $i += $this->davSync();

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

                   */

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

                                  $orgUserId = App\User::getCurrentUserId();

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

                                  self::$cache[$userId][$this->record['id']] = true;

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

                   * Dav create.

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

                      $calUri = $uid . '.ics';

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

                          'uri' => $calUri,

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

                          'lastoccurence' => $extraData['lastOccurence'],

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

                      $instance->loadFromArray($this->record);

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

                  public $calendarId = false;

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

                      $dataReader = $query->createCommand()->query();

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

                      \App\Log::trace(__METHOD__ . ' | End');

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

                          if ($isPermitted) {

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

                                  App\User::setCurrentUserId($userId);

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

                                  $event = $this->getDavDetail();

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

                          }

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

                          'calendardata' => $calendarData,

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

                   * @param array $dav

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

                  const COMPONENTS = 'VEVENT,VTODO';

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

                   * Record.

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

                   * @var int

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

                  public $davUsers = [];

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

                              if (false !== $exclusion) {

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

                                  if (false === $event) {

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

                      }

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

                      \App\Log::trace("Calendar end - CRM >> DAV | create: $create | updates: $updates", __METHOD__);

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

                          'etag' => $extraData['etag'],

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

                  public function davUpdate($dav)

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

                      $instance = \App\Integrations\Dav\Calendar::loadFromDav($dav['calendardata']);

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

                  /**

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

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

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

                                  }

              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->davSaveAttendee($this->record);

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

                   * @var bool|mixed

              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

                      $queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);

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

                          $instance->davSaveAttendee($this->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

                   */

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

                          $this->record = $row;

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

                  /**

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

                              $exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_TO_DAV');

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

                                      if ($this->record[$key] == $value) {

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

                      \App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);

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

                          'componenttype' => $extraData['componentType'],

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

                      $component = $instance->getComponent();

              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

                      $dataReader->close();

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

                                      ++$updates;

              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

                          'uid' => $uid,

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

                      $calendar = $instance->getVCalendar();

              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

                   * Dav users.

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

                   * @var array

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

                   * Cache.

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

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

                      \App\Log::trace(__METHOD__ . ' | Start');

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

                      $queryGenerator = new \App\QueryGenerator('Calendar');

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

                  }

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

                  {

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

                      foreach ($this->davUsers as $userId => $user) {

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

                      $extraData = $instance->getDenormalizedData($calendarData);

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

                   * Components.

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

                  /**

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

                   *

              Line exceeds 120 characters; contains 278 characters
              Open

                      $queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);

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

              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->loadFromArray($this->record);

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

                          'size' => $extraData['size'],

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

                      \App\Log::trace(__METHOD__ . ' | 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

                   * @var array

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

                      $query->where(['vtiger_crmentity.deleted' => 0, 'vtiger_activity.dav_status' => 1]);

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

                          $isPermitted = !isset(self::$cache[$userId][$this->record['id']]) && !$this->toDelete($this->record);

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

                                          $isPermitted = false;

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

                                  App\User::setCurrentUserId($orgUserId);

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

                      $this->recordMarkComplete();

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

                      $instance = \App\Integrations\Dav\Calendar::createEmptyInstance();

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

              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

                      $queryGenerator->setCustomColumn(['vtiger_crmentity.deleted']);

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

                      }

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

                   * Dav sync.

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

                   *

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

                                      ++$create;

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

                                  } elseif (strtotime($this->record['modifiedtime']) > $event['lastmodified']) { // Updating

              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 $create + $updates;

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

                          'firstoccurence' => $extraData['firstOccurence'],

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

                      if ('VEVENT' === (string) $component->name) {

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

                   */

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

                   */

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

                   * Sync from CRM to DAV.

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

                      return $i;

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

                                      $this->davCreate();

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

                      $component = $instance->createComponent();

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

                   * Dav update.

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

                      \App\Integrations\Dav\Calendar::addChange($this->calendarId, $dav['uri'], 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

                      return $i;

              Line exceeds 120 characters; contains 143 characters
              Open

                      \App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);

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

                      $calendarData = $calendar->serialize();

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

                          'etag' => $extraData['etag'],

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

                          'firstoccurence' => $extraData['firstOccurence'],

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

                      \App\Log::trace(__METHOD__ . ' | End');

              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

                      \App\Log::trace(__METHOD__ . ' | Start');

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

                          $this->calendarId = $user->get('calendarsid');

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

                   * Sync record.

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

                          $i += $this->recordSync();

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

                      foreach ($this->davUsers as $user) {

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

                          'lastoccurence' => $extraData['lastOccurence'],

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

                          'crmid' => $this->record['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

                  public function recordSync(): int

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

                      $query = (new \App\Db\Query())->select([

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

                          'calendardata' => $calendarData,

              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

                      \App\Log::trace('Start', __METHOD__);

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

                          'size' => $extraData['size'],

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

                  public function dav2Crm(): int

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

                          $this->user = $user;

              Line exceeds 120 characters; contains 123 characters
              Open

                          'vtiger_crmentity.modifiedtime', 'vtiger_crmentity.setype',    'assigned_user_id' => 'vtiger_crmentity.smownerid',

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

                          'componenttype' => $extraData['componentType'],

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

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

                      ], ['id' => $dav['id']]

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

                   *

              Line exceeds 120 characters; contains 121 characters
              Open

                                  if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {

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

                      $extraData = $instance->getDenormalizedData($calendarData);

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

                  {

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

                          'dav_calendarobjects.*',

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

                      \App\Db::getInstance()->createCommand()->update('dav_calendarobjects', [

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

                          'uid' => $extraData['uid'],

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

                      \App\Log::trace(__METHOD__ . ' | End');

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

                          'lastmodified' => strtotime($this->record['modifiedtime']),

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

                   * Sync from DAV to CRM.

              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

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

                          'vtiger_crmentity.modifiedtime', 'vtiger_crmentity.setype',    'assigned_user_id' => 'vtiger_crmentity.smownerid',

              Line exceeds 120 characters; contains 149 characters
              Open

                      return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();

              Line exceeds 120 characters; contains 248 characters
              Open

                              $isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($cal['assigned_user_id'], $this->user->get('groups')) || \in_array($userId, $shownerIds) || \count(array_intersect($shownerIds, $this->user->get('groups'))) > 0;

              Line exceeds 120 characters; contains 142 characters
              Open

                              $isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($userId, \App\Fields\SharedOwner::getById($cal['id']));

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

              class API_CalDAV_Model

              Expected 0 spaces before closing bracket; newline found
              Open

                          $dbCommand->update('vtiger_crmentity', [

              Expected 0 spaces before closing bracket; newline found
              Open

                      \App\Db::getInstance()->createCommand()->update('dav_calendarobjects', [

              Expected 0 spaces before closing bracket; newline found
              Open

                          $dbCommand->update('dav_calendarobjects', [

              Expected 0 spaces before closing bracket; newline found
              Open

                          $dbCommand->update('dav_calendarobjects', [

              Expected 0 spaces before closing bracket; newline found
              Open

                      App\Db::getInstance()->createCommand()->update('vtiger_activity', [

              Expected 0 spaces before closing bracket; newline found
              Open

                          $dbCommand->update('vtiger_crmentity', [

              There are no issues that match your filters.

              Category
              Status