YetiForceCompany/YetiForceCRM

View on GitHub
app/Integrations/Dav/Card.php

Summary

Maintainability
D
2 days
Test Coverage
F
11%

Function parsePhone has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private function parsePhone(): void
    {
        $country = null;
        if ($userId = $this->user ? $this->user->getId() : null) {
            $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
Severity: Minor
Found in app/Integrations/Dav/Card.php - About 4 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

class Card
{
    /** @var array Address mapping for modules. */
    const ADDRESS_MAPPING = [
        'Contacts' => [
Severity: Minor
Found in app/Integrations/Dav/Card.php by phpmd

Function setValuesForRecord has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function setValuesForRecord(\Vtiger_Record_Model $record): void
    {
        $this->record = $record;
        if (isset($this->card->N)) {
            $head = $this->card->N->getParts();
Severity: Minor
Found in app/Integrations/Dav/Card.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

Function parseMail has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseMail(): void
    {
        $moduleName = $this->record->getModuleName();
        $usedTypes = [];
        foreach (self::MAIL_FIELDS[$moduleName] as $key => $type) {
Severity: Minor
Found in app/Integrations/Dav/Card.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

File Card.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * CardDav address books file.
 *
 * @see https://en.wikipedia.org/wiki/VCard#Properties
Severity: Minor
Found in app/Integrations/Dav/Card.php - About 2 hrs to fix

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

        public function setRecordAddress(string $moduleName, \Vtiger_Record_Model $record): void
        {
            foreach ($this->card->ADR as $property) {
                if ($typeOfAddress = $this->getTypeOfAddress($property)) {
                    $address = $this->convertAddress($property->getParts());
    Severity: Minor
    Found in app/Integrations/Dav/Card.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 setValuesForRecord has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function setValuesForRecord(\Vtiger_Record_Model $record): void
        {
            $this->record = $record;
            if (isset($this->card->N)) {
                $head = $this->card->N->getParts();
    Severity: Minor
    Found in app/Integrations/Dav/Card.php - About 1 hr to fix

      Method parsePhone has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function parsePhone(): void
          {
              $country = null;
              if ($userId = $this->user ? $this->user->getId() : null) {
                  $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
      Severity: Minor
      Found in app/Integrations/Dav/Card.php - About 1 hr to fix

        Function setValuesForCreateRecord has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setValuesForCreateRecord(\Vtiger_Record_Model $record): void
            {
                if ('Contacts' === $record->getModuleName() && isset($this->card->ORG)) {
                    $lead = \Vtiger_Record_Model::getCleanInstance('Leads');
                    $lead->set('assigned_user_id', $this->user->get('id'));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php - About 25 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 setValuesForRecord() has an NPath complexity of 6336. The configured NPath complexity threshold is 200.
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        NPathComplexity

        Since: 0.1

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

        Example

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

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

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

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 parsePhone() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
        Open

            private function parsePhone(): void
            {
                $country = null;
                if ($userId = $this->user ? $this->user->getId() : null) {
                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 31 to the 15 allowed.
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 20 to the 15 allowed.
        Open

            private function parseMail(): void
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 34 to the 15 allowed.
        Open

            private function parsePhone(): void
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 '120', column '22').
        Open

                $dataReader = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 '162', column '15').
        Open

                return (new \App\Db\Query())->from('dav_addressbooks')->where(['id' => $id])->one();
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'setValuesForRecord'.
        Open

                    $record->set('description', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->NOTE)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'parsePhone'.
        Open

                                $orgPhone = \App\Purifier::purify($t->getValue());
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '198', column '28').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

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

                    'city' => \App\Purifier::purify($addressFromVCard[3]),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Country' in method 'convertAddress'.
        Open

                    'country' => \App\Fields\Country::findCountryName(\App\Purifier::purify($addressFromVCard[6])),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'convertAddress'.
        Open

                    'postCode' => \App\Purifier::purify($addressFromVCard[5]),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'convertAddress'.
        Open

                    'postOfficeBox' => \App\Purifier::purify($addressFromVCard[0]),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'setValuesForRecord'.
        Open

                        $record->set('firstname', $fieldModel->getDBValue(\App\Purifier::purify($head[1])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '351', column '8').
        Open

            public function setRecordAddress(string $moduleName, \Vtiger_Record_Model $record): void
            {
                foreach ($this->card->ADR as $property) {
                    if ($typeOfAddress = $this->getTypeOfAddress($property)) {
                        $address = $this->convertAddress($property->getParts());
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

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

                        $record->set('name', $fieldModel->getDBValue(\App\Purifier::purify($head[1])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '208', column '36').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid assigning values to variables in if clauses and the like (line '358', column '10').
        Open

            public function setRecordAddress(string $moduleName, \Vtiger_Record_Model $record): void
            {
                foreach ($this->card->ADR as $property) {
                    if ($typeOfAddress = $this->getTypeOfAddress($property)) {
                        $address = $this->convertAddress($property->getParts());
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

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

                        $record->set('lastname', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'setValuesForRecord'.
        Open

                        $record->set('jobtitle', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->TITLE)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'convertAddress'.
        Open

                    'street' => \App\Purifier::purify(trim($addressFromVCard[2])),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'setValuesForRecord'.
        Open

                        $record->set('last_name', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'convertAddress'.
        Open

                    'localNumber' => \App\Purifier::purify($addressFromVCard[1]),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '201', column '28').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid assigning values to variables in if clauses and the like (line '194', column '39').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid assigning values to variables in if clauses and the like (line '231', column '8').
        Open

            public function setValuesForCreateRecord(\Vtiger_Record_Model $record): void
            {
                if ('Contacts' === $record->getModuleName() && isset($this->card->ORG)) {
                    $lead = \Vtiger_Record_Model::getCleanInstance('Leads');
                    $lead->set('assigned_user_id', $this->user->get('id'));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid assigning values to variables in if clauses and the like (line '258', column '36').
        Open

            private function parsePhone(): void
            {
                $country = null;
                if ($userId = $this->user ? $this->user->getId() : null) {
                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid using static access to class '\App\Fields\Country' in method 'parsePhone'.
        Open

                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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\Purifier' in method 'parseMail'.
        Open

                                $this->record->set($key, $fieldModel->getDBValue(\App\Purifier::purify($e->getValue())));
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '185', column '28').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid assigning values to variables in if clauses and the like (line '188', column '38').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

        Avoid assigning values to variables in if clauses and the like (line '252', column '7').
        Open

            private function parsePhone(): void
            {
                $country = null;
                if ($userId = $this->user ? $this->user->getId() : null) {
                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

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

                    'country' => \App\Fields\Country::findCountryName(\App\Purifier::purify($addressFromVCard[6])),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 '\Sabre\VObject\Reader' in method 'loadFromContent'.
        Open

                $instance->card = \Sabre\VObject\Reader::read($content);
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '297', column '38').
        Open

            private function parseMail(): void
            {
                $moduleName = $this->record->getModuleName();
                $usedTypes = [];
                foreach (self::MAIL_FIELDS[$moduleName] as $key => $type) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

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

                    'state' => \App\Purifier::purify($addressFromVCard[4]),
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 assigning values to variables in if clauses and the like (line '182', column '28').
        Open

            public function setValuesForRecord(\Vtiger_Record_Model $record): void
            {
                $this->record = $record;
                if (isset($this->card->N)) {
                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

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

        Example

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

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

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

                    $lead = \Vtiger_Record_Model::getCleanInstance('Leads');
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 "synctoken" 3 times.
        Open

                $syncToken = (int) static::getAddressBook($addressBookId)['synctoken'];
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "Contacts" 5 times.
        Open

                'Contacts' => [
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "country" 6 times.
        Open

                        'addresslevel1a' => ['country'],
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "state" 6 times.
        Open

                        'addresslevel2a' => ['state'],
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "postCode" 5 times.
        Open

                        'addresslevel7a' => ['postCode'],
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "localNumber" 5 times.
        Open

                        'localnumbera' => ['localNumber'],
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "OSSEmployees" 4 times.
        Open

                'OSSEmployees' => [
        Severity: Critical
        Found in app/Integrations/Dav/Card.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 "street" 6 times.
        Open

                        'addresslevel8a' => ['street'],
        Severity: Critical
        Found in app/Integrations/Dav/Card.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.

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

                    if (isset($this->card->GENDER) && ($fieldModel = $record->getField('salutationtype'))) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                if (isset($this->card->ADR)) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $record->set('firstname', $fieldModel->getDBValue(\App\Purifier::purify($head[1])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                        $record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                if (isset($this->card->NOTE) && ($fieldModel = $record->getField('description'))) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                    $record->set('description', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->NOTE)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                return (new \App\Db\Query())->from('dav_addressbooks')->where(['id' => $id])->one();
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

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

                    if (isset($this->card->BDAY) && $record->getField('birth_date')) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                foreach ($this->card->ADR as $property) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                    $head = $this->card->FN->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                    if (isset($this->card->TEL) && ($fieldModel = $this->record->getField($key))) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                $dataReader = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

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

                    $head = $this->card->N->getParts();
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                } elseif (isset($this->card->FN)) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $record->set('lastname', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Reference to undeclared property \App\Integrations\Dav\Card->records (Did you mean expr->record)
        Open

                    $instance->records[$uid] = $recordModel;
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                        $record->set('jobtitle', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->TITLE)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                        $record->set('birth_date', date('Y-m-d', strtotime($this->card->BDAY)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $lead->set('company', $fieldModel->getDBValue((string) $this->card->ORG));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Reference to instance property parameters from undeclared class \Sabre\VObject\Property
        Open

                foreach ($property->parameters as $parameter) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Property \App\Integrations\Dav\Card->card has undeclared type \Sabre\VObject\Component\VCard
        Open

            private $card;
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                $dbCommand = \App\Db::getInstance()->createCommand();
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

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

                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                                $this->record->set($key, $fieldModel->getDBValue($orgPhone));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                                $this->record->set($key, $fieldModel->getDBValue(\App\Purifier::purify($e->getValue())));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $record->set('last_name', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                if (isset($this->card->N)) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $record->set('jobtitle', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->TITLE)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                if ('Contacts' === $record->getModuleName() && isset($this->card->ORG)) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                    if (isset($this->card->EMAIL) && ($fieldModel = $this->record->getField($key))) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                        $record->set('name', $fieldModel->getDBValue(\App\Purifier::purify($head[1])));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Doc-block of $property in getTypeOfAddress contains phpdoc param type mixed which is incompatible with the param type \Sabre\VObject\Property declared in the signature
        Open

             * @param mixed $property
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Return type of getVCard() is undeclared type \Sabre\VObject\Component\VCard
        Open

            public function getVCard(): \Sabre\VObject\Component\VCard
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Call to undeclared method \Vtiger_Base_UIType::getPhoneDetails
        Open

                                    $details = $fieldModel->getUITypeModel()->getPhoneDetails($orgPhone, $country);
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

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

                    if (isset($this->card->TITLE) && ($fieldModel = $record->getField('jobtitle'))) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                                $record->set($fieldName, $fieldModel->getDBValue(implode(' ', $fieldsForJoin)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                        $record->set('birthday', date('Y-m-d', strtotime($this->card->BDAY)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Argument 1 (value) is string but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
        Open

                    $record->set('description', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->NOTE)));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Parameter $property has undeclared type \Sabre\VObject\Property
        Open

            private function getTypeOfAddress(\Sabre\VObject\Property $property): ?string
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

        Call to method read from undeclared class \Sabre\VObject\Reader
        Open

                $instance->card = \Sabre\VObject\Reader::read($content);
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

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

                $dbCommand = \App\Db::getInstance()->createCommand();
        Severity: Critical
        Found in app/Integrations/Dav/Card.php by phan

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

                        $lead->set('company', $fieldModel->getDBValue((string) $this->card->ORG));
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                        foreach ($this->card->EMAIL as $e) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                    if (isset($this->card->BDAY) && 8 === \strlen($this->card->BDAY) && $record->getField('birthday')) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

                        foreach ($this->card->TEL as $t) {
        Severity: Minor
        Found in app/Integrations/Dav/Card.php by phan

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

            public static function deleteByCrmId(int $id): void
            {
                $dbCommand = \App\Db::getInstance()->createCommand();
                $dataReader = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();
                $dbCommand->delete('dav_cards', ['crmid' => $id])->execute();
        Severity: Major
        Found in app/Integrations/Dav/Card.php and 1 other location - About 2 hrs to fix
        app/Integrations/Dav/Calendar.php on lines 79..88

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

        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

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

            public static function deleteByCrmId(int $id): void
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 $id. Configured minimum length is 3.
        Open

            public static function getAddressBook(int $id)
        Severity: Minor
        Found in app/Integrations/Dav/Card.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 to indent lines; tabs are not allowed
        Open

            /** @var array Address mapping for modules. */

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

                    'HOME' => [

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

                        'ship_code' => ['postCode'],

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

                    ],

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

                        'addresslevel2a' => ['state'],

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

                    ],

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

                        'addresslevel1b' => ['country'],

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

                ],

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

                    'WORK' => [

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

                        'code' => ['postCode'],

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

                        'city' => ['city'],

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

                    'WORK' => [

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

                        'localnumbera' => ['localNumber'],

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

                        'localnumberb' => ['localNumber'],

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

                        'addresslevel2b' => ['state'],

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

                        'addresslevel8b' => ['street'],

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

                'Contacts' => [

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

                    ],

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

                        'state' => ['state'],

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

                        'street' => ['street', 'localNumber'],

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

                ],

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

                    'HOME' => [

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

                        'addresslevel8a' => ['street'],

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

                        'ship_state' => ['state'],

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

                        'ship_city' => ['city'],

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

                        'addresslevel7a' => ['postCode'],

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

                    ],

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

                        'ship_street' => ['street', 'localNumber'],

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

            const ADDRESS_MAPPING = [

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

                        'addresslevel1a' => ['country'],

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

                        'addresslevel7b' => ['postCode'],

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

                        'addresslevel5b' => ['city'],

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

                'OSSEmployees' => [

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

                        'ship_country' => ['country'],

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

                        'addresslevel5a' => ['city'],

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

                        'country' => ['country'],

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

                'Contacts' => ['email' => 'WORK', 'secondary_email' => 'HOME'],

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

            const PHONE_FIELDS = [

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

            /** @var \Users_Record_Model User record model. */

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

            public $user;

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

             * @param string|null               $uid

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

                $instance->card = \Sabre\VObject\Reader::read($content);

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

             * Get card instance.

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

             * @return \Sabre\VObject\Component\VCard

        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 = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();

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

                $dbCommand->delete('dav_cards', ['crmid' => $id])->execute();

        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

                    'operation' => $operation,

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

             *

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

             *

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

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

                    $head = $this->card->FN->getParts();

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

                }

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

                $moduleName = $record->getModuleName();

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

                        $record->set('lastname', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));

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

                        $record->set('jobtitle', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->TITLE)));

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

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

            private $card;

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

             * Load from content.

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

            public static function loadFromContent(string $content, ?\Vtiger_Record_Model $recordModel = null, ?string $uid = null): self

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

                if ($recordModel && $uid) {

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

                return $this->card;

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

             * @return void

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

             *

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

                    $head = $this->card->N->getParts();

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

                    if (isset($this->card->GENDER) && ($fieldModel = $record->getField('salutationtype'))) {

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

                    }

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

                if (isset($this->card->ADR)) {

        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 self

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

            }

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

                    ->execute();

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

            {

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

                    }

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

                    if (isset($head[0]) && ($fieldModel = $record->getField('last_name'))) {

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

             * @param string                    $content

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

             */

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

             *

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

                if ('Contacts' === $moduleName) {

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

                }

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

             */

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

            /**

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

             *

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

            }

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

             * @return void

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

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

                'OSSEmployees' => ['business_mail' => 'WORK', 'private_mail' => 'HOME'],

        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

                    'synctoken' => $syncToken,

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

                        $record->set('firstname', $fieldModel->getDBValue(\App\Purifier::purify($head[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

                ], ['id' => $addressBookId])

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

             * @return array

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

                if (isset($this->card->N)) {

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

                        $record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));

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

             *

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

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

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

                $syncToken = (int) static::getAddressBook($addressBookId)['synctoken'];

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

                $dbCommand->update('dav_addressbooks', [

        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

                        $record->set('name', $fieldModel->getDBValue(\App\Purifier::purify($head[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

                    $this->setRecordAddress($moduleName, $record);

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

             * @param int $id

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

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

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

                while ($addressBookId = $dataReader->readColumn(0)) {

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

                    static::addChange($addressBookId, $id . '.vcf', 3);

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

             * @param int    $operation

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

            {

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

                    'synctoken' => $syncToken + 1,

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

             * @param int $id

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

                    if (isset($head[1]) && ($fieldModel = $record->getField('firstname'))) {

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

                        $record->set('birth_date', date('Y-m-d', strtotime($this->card->BDAY)));

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

                'OSSEmployees' => ['business_phone' => 'WORK', 'private_phone' => 'CELL', 'secondary_phone' => 'OTHER'],

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

                    $instance->records[$uid] = $recordModel;

        Line exceeds 120 characters; contains 141 characters
        Open

                $dataReader = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();

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

            /**

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

             *

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

             * Get address books.

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

                return (new \App\Db\Query())->from('dav_addressbooks')->where(['id' => $id])->one();

        Line exceeds 120 characters; contains 124 characters
        Open

                        $record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));

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

                    }

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

                    if (isset($head[1]) && ($fieldModel = $record->getField('name'))) {

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

                'Contacts' => ['phone' => 'WORK', 'mobile' => 'CELL'],

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

            /** @var \Sabre\VObject\Component\VCard Card object. */

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

            {

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

             * Delete card by crm 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

                    'uri' => $uri,

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

             * @param \Vtiger_Record_Model $record

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

            public function setValuesForRecord(\Vtiger_Record_Model $record): void

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

                if (isset($this->card->NOTE) && ($fieldModel = $record->getField('description'))) {

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

            /** @var array Mail fields. */

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

             */

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

            {

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

             * @param string $uri

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

                    'addressbookid' => $addressBookId,

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

            ];

        Line exceeds 120 characters; contains 129 characters
        Open

            public static function loadFromContent(string $content, ?\Vtiger_Record_Model $recordModel = null, ?string $uid = null): self

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

             *

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

            public static function deleteByCrmId(int $id): void

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

                    }

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

                        $record->set('birthday', date('Y-m-d', strtotime($this->card->BDAY)));

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

                        $record->set('last_name', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));

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

                    if (isset($this->card->BDAY) && $record->getField('birth_date')) {

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

            /** @var array Phone fields. */

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

            private $record;

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

             * @param \Vtiger_Record_Model|null $recordModel

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

                $instance = new self();

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

            {

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

            public static function addChange(int $addressBookId, string $uri, int $operation): void

        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

             * Set values for 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

                    if (isset($this->card->BDAY) && 8 === \strlen($this->card->BDAY) && $record->getField('birthday')) {

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

                } elseif ('OSSEmployees' === $moduleName) {

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

            /** @var \Vtiger_Record_Model Record model. */

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

             * @return void

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

            }

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

             * @param int    $addressBookId

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

            }

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

                    }

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

                    if (isset($this->card->TITLE) && ($fieldModel = $record->getField('jobtitle'))) {

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

                    $record->set('description', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->NOTE)));

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

                        $record->set($fieldModel->getFieldName(), $lead->getId());

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

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

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

            {

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

                }

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

                                $types[] = 'WORK';

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

                                $usedTypes = array_merge($usedTypes, $types);

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

                            if (\in_array($type, $types)) {

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

             *

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

             * @param string $gender

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

                    case 'M':

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

                    default:

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

                        $salutation = '';

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

                return $salutation;

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

             */

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

            /**

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

                    if (isset($this->card->TEL) && ($fieldModel = $this->record->getField($key))) {

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

                            if (\in_array($type, $types)) {

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

                    if (isset($this->card->EMAIL) && ($fieldModel = $this->record->getField($key))) {

        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

            const MAIL_FIELDS = [

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

            }

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

            /**

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

             *

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

                return $instance;

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

            public function setValuesForCreateRecord(\Vtiger_Record_Model $record): void

        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 getVCard(): \Sabre\VObject\Component\VCard

        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 ('Contacts' === $record->getModuleName() && isset($this->card->ORG)) {

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

                }

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

                    $lead->save();

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

             * Add change to address books .

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

            }

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

                $dbCommand->insert('dav_addressbookchanges', [

        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 (self::PHONE_FIELDS[$moduleName] as $key => $type) {

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

            public static function getAddressBook(int $id)

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

                                    $details = $fieldModel->getUITypeModel()->getPhoneDetails($orgPhone, $country);

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

                } elseif (isset($this->card->FN)) {

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

                                    $orgPhone = $details['number'];

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

                    if (isset($head[0]) && ($fieldModel = $record->getField('lastname'))) {

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

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

             * @param array $addressFromVCard

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

                        foreach ($this->card->EMAIL as $e) {

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

                            $types = [];

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

                            }

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

                        }

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

             * @return string

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

                }

        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 ($fieldModel = $record->getField($fieldName)) {

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

                    }

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

             *

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

             *

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

                    $fieldModel = current($record->getModule()->getReferenceFieldsForModule('Leads'));

        Line exceeds 120 characters; contains 136 characters
        Open

                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));

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

            /**

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

                        $type = strtoupper($type);

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

                            foreach ($e->parameters() as $p) {

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

                                $cardType = explode(',', $p->getValue());

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

                                $types[] = strtoupper(array_reverse($cardType)[0]);

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

            private function getCardGender(string $gender): string

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

             * @return void

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

            private function parsePhone(): void

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

                    $country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));

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

                $usedTypes = [];

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

                $moduleName = $this->record->getModuleName();

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

             * Parse email.

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

                            }

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

                                $usedTypes = array_merge($usedTypes, $types);

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

                }

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

                                $fieldsForJoin[] = $address[$val];

        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 ($fieldModel = $lead->getField('company')) {

        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 ($t->parameters() as $p) {

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

            }

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

                                $record->set($fieldName, $fieldModel->getDBValue(implode(' ', $fieldsForJoin)));

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

            }

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

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

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

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

                    $lead->set('leadstatus', 'PLL_PENDING');

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

                    if ($fieldModel) {

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

                if ($userId = $this->user ? $this->user->getId() : null) {

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

                        $type = strtoupper($type);

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

                                $cardType = explode(',', $p->getValue());

        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

                        break;

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

                    case 'F':

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

                $this->setValuesForRecord($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

             *

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

             * @return void

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

            private function parseMail(): void

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

                                $types[] = 'WORK';

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

                    }

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

             *

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

                                    if ($key !== $details['fieldName']) {

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

                foreach (self::MAIL_FIELDS[$moduleName] as $key => $type) {

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

                            }

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

             * @param string               $moduleName

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

                foreach ($this->card->ADR as $property) {

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

                            $fieldsForJoin = [];

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

                    'street' => \App\Purifier::purify(trim($addressFromVCard[2])),

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

                    'postOfficeBox' => \App\Purifier::purify($addressFromVCard[0]),

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

             * Get type of address.

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

                    $type = $parameter->jsonSerialize()[0];

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

             * @return string|null

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

             */

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

             *

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

                        break;

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

            {

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

                $usedTypes = [];

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

             * @return void

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

                        $address = $this->convertAddress($property->getParts());

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

             * Convert address.

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

             *

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

             * @return string[]

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

            {

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

            }

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

             */

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

                            if (!$types && !\in_array('WORK', $usedTypes)) {

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

                                        continue;

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

                        break;

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

                        break;

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

            /**

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

                    'country' => \App\Fields\Country::findCountryName(\App\Purifier::purify($addressFromVCard[6])),

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

                    'postCode' => \App\Purifier::purify($addressFromVCard[5]),

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

             *

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

                        $typeOfAddress = $type;

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

                        $lead->set('company', $fieldModel->getDBValue((string) $this->card->ORG));

        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->card->TEL as $t) {

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

                            }

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

                $moduleName = $this->record->getModuleName();

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

             * Get card gender).

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

                switch ($gender) {

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

                        $salutation = 'Mr.';

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

                        foreach (static::ADDRESS_MAPPING[$moduleName][$typeOfAddress] ?? [] as $fieldName => $fieldsInVCard) {

        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 void

        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

             * Parse phone.

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

                                $types[] = strtoupper($cardType[0]);

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

                            if (!$types && !\in_array('WORK', $usedTypes)) {

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

                                $this->record->set($key, $fieldModel->getDBValue(\App\Purifier::purify($e->getValue())));

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

             */

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

                        $salutation = 'Mrs.';

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

            /**

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

             * Set record address.

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

             *

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

                    if ($typeOfAddress = $this->getTypeOfAddress($property)) {

        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 ('WORK' === $type || 'HOME' == $type) {

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

             * Set values for create record.

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

                            $types = [];

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

                                $orgPhone = \App\Purifier::purify($t->getValue());

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

                                        $this->record->set($details['fieldName'], $details['number']);

        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 ($fieldsInVCard as $val) {

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

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

             */

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

            private function convertAddress(array $addressFromVCard): 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

                foreach ($property->parameters as $parameter) {

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

                return [

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

            private function getTypeOfAddress(\Sabre\VObject\Property $property): ?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

                $typeOfAddress = null;

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

                }

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

                    $lead = \Vtiger_Record_Model::getCleanInstance('Leads');

        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

                $country = null;

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

                            }

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

                                if ($orgPhone && 'phone' === $fieldModel->getFieldDataType()) {

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

                                $this->record->set($key, $fieldModel->getDBValue($orgPhone));

        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 setRecordAddress(string $moduleName, \Vtiger_Record_Model $record): void

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

                            }

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

                    'state' => \App\Purifier::purify($addressFromVCard[4]),

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

                    'city' => \App\Purifier::purify($addressFromVCard[3]),

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

                    'localNumber' => \App\Purifier::purify($addressFromVCard[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

             * @param mixed $property

        There are no issues that match your filters.

        Category
        Status