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'));
- Read upRead up
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' => [
- Exclude checks
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();
- Read upRead up
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) {
- Read upRead up
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
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());
- Read upRead up
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();
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'));
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'));
- Read upRead up
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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)));
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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]),
- Read upRead up
- Exclude checks
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])),
- Read upRead up
- Exclude checks
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]),
- Read upRead up
- Exclude checks
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]),
- Read upRead up
- Exclude checks
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])));
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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])));
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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])));
- Read upRead up
- Exclude checks
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)));
- Read upRead up
- Exclude checks
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])),
- Read upRead up
- Exclude checks
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])));
- Read upRead up
- Exclude checks
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]),
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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())));
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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])),
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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]),
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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'];
- Read upRead up
- Exclude checks
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' => [
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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' => [
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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'))) {
- Exclude checks
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)));
- Exclude checks
Reference to instance property ADR
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->ADR)) {
- Exclude checks
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])));
- Exclude checks
Reference to instance property GENDER
from undeclared class \Sabre\VObject\Component\VCard
Open
$record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));
- Exclude checks
Reference to instance property NOTE
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->NOTE) && ($fieldModel = $record->getField('description'))) {
- Exclude checks
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)));
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new \App\Db\Query())->from('dav_addressbooks')->where(['id' => $id])->one();
- Exclude checks
Reference to instance property BDAY
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->BDAY) && $record->getField('birth_date')) {
- Exclude checks
Reference to instance property ADR
from undeclared class \Sabre\VObject\Component\VCard
Open
foreach ($this->card->ADR as $property) {
- Exclude checks
Reference to instance property FN
from undeclared class \Sabre\VObject\Component\VCard
Open
$head = $this->card->FN->getParts();
- Exclude checks
Reference to instance property TEL
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->TEL) && ($fieldModel = $this->record->getField($key))) {
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();
- Exclude checks
Reference to instance property N
from undeclared class \Sabre\VObject\Component\VCard
Open
$head = $this->card->N->getParts();
- Exclude checks
Reference to instance property FN
from undeclared class \Sabre\VObject\Component\VCard
Open
} elseif (isset($this->card->FN)) {
- Exclude checks
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])));
- Exclude checks
Reference to undeclared property \App\Integrations\Dav\Card->records
(Did you mean expr->record) Open
$instance->records[$uid] = $recordModel;
- Exclude checks
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)));
- Exclude checks
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)));
- Exclude checks
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));
- Exclude checks
Reference to instance property parameters
from undeclared class \Sabre\VObject\Property
Open
foreach ($property->parameters as $parameter) {
- Exclude checks
Property \App\Integrations\Dav\Card->card
has undeclared type \Sabre\VObject\Component\VCard
Open
private $card;
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
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'));
- Exclude checks
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));
- Exclude checks
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())));
- Exclude checks
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])));
- Exclude checks
Reference to instance property N
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->N)) {
- Exclude checks
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)));
- Exclude checks
Reference to instance property ORG
from undeclared class \Sabre\VObject\Component\VCard
Open
if ('Contacts' === $record->getModuleName() && isset($this->card->ORG)) {
- Exclude checks
Reference to instance property EMAIL
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->EMAIL) && ($fieldModel = $this->record->getField($key))) {
- Exclude checks
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])));
- Exclude checks
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
- Exclude checks
Return type of getVCard()
is undeclared type \Sabre\VObject\Component\VCard
Open
public function getVCard(): \Sabre\VObject\Component\VCard
- Exclude checks
Call to undeclared method \Vtiger_Base_UIType::getPhoneDetails
Open
$details = $fieldModel->getUITypeModel()->getPhoneDetails($orgPhone, $country);
- Exclude checks
Reference to instance property TITLE
from undeclared class \Sabre\VObject\Component\VCard
Open
if (isset($this->card->TITLE) && ($fieldModel = $record->getField('jobtitle'))) {
- Exclude checks
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)));
- Exclude checks
Reference to instance property BDAY
from undeclared class \Sabre\VObject\Component\VCard
Open
$record->set('birthday', date('Y-m-d', strtotime($this->card->BDAY)));
- Exclude checks
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)));
- Exclude checks
Parameter $property
has undeclared type \Sabre\VObject\Property
Open
private function getTypeOfAddress(\Sabre\VObject\Property $property): ?string
- Exclude checks
Call to method read
from undeclared class \Sabre\VObject\Reader
Open
$instance->card = \Sabre\VObject\Reader::read($content);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Reference to instance property ORG
from undeclared class \Sabre\VObject\Component\VCard
Open
$lead->set('company', $fieldModel->getDBValue((string) $this->card->ORG));
- Exclude checks
Reference to instance property EMAIL
from undeclared class \Sabre\VObject\Component\VCard
Open
foreach ($this->card->EMAIL as $e) {
- Exclude checks
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')) {
- Exclude checks
Reference to instance property TEL
from undeclared class \Sabre\VObject\Component\VCard
Open
foreach ($this->card->TEL as $t) {
- Exclude checks
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();
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid variables with short names like $id. Configured minimum length is 3. Open
public static function deleteByCrmId(int $id): void
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'HOME' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ship_code' => ['postCode'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel2a' => ['state'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel1b' => ['country'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'WORK' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'code' => ['postCode'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => ['city'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'WORK' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'localnumbera' => ['localNumber'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'localnumberb' => ['localNumber'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel2b' => ['state'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel8b' => ['street'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Contacts' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'state' => ['state'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'street' => ['street', 'localNumber'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'HOME' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel8a' => ['street'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ship_state' => ['state'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ship_city' => ['city'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel7a' => ['postCode'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ship_street' => ['street', 'localNumber'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const ADDRESS_MAPPING = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel1a' => ['country'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel7b' => ['postCode'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel5b' => ['city'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'OSSEmployees' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ship_country' => ['country'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel5a' => ['city'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => ['country'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Contacts' => ['email' => 'WORK', 'secondary_email' => 'HOME'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const PHONE_FIELDS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \Users_Record_Model User record model. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $uid
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->card = \Sabre\VObject\Reader::read($content);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get card instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Sabre\VObject\Component\VCard
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
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();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->delete('dav_cards', ['crmid' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'operation' => $operation,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->record = $record;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$head = $this->card->FN->getParts();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $record->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('lastname', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('jobtitle', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->TITLE)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->parsePhone();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $card;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load from content.
- Exclude checks
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
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recordModel && $uid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->card;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$head = $this->card->N->getParts();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->GENDER) && ($fieldModel = $record->getField('salutationtype'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->ADR)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($head[0]) && ($fieldModel = $record->getField('last_name'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $content
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Contacts' === $moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->parseMail();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'OSSEmployees' => ['business_mail' => 'WORK', 'private_mail' => 'HOME'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'synctoken' => $syncToken,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('firstname', $fieldModel->getDBValue(\App\Purifier::purify($head[1])));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], ['id' => $addressBookId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->N)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$syncToken = (int) static::getAddressBook($addressBookId)['synctoken'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->update('dav_addressbooks', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('name', $fieldModel->getDBValue(\App\Purifier::purify($head[1])));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setRecordAddress($moduleName, $record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($addressBookId = $dataReader->readColumn(0)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::addChange($addressBookId, $id . '.vcf', 3);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $operation
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'synctoken' => $syncToken + 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($head[1]) && ($fieldModel = $record->getField('firstname'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('birth_date', date('Y-m-d', strtotime($this->card->BDAY)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'OSSEmployees' => ['business_phone' => 'WORK', 'private_phone' => 'CELL', 'secondary_phone' => 'OTHER'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->records[$uid] = $recordModel;
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$dataReader = (new \App\Db\Query())->select(['addressbookid'])->from('dav_cards')->where(['crmid' => $id])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get address books.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->from('dav_addressbooks')->where(['id' => $id])->one();
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
$record->set('salutationtype', $fieldModel->getDBValue($this->getCardGender((string) $this->card->GENDER)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($head[1]) && ($fieldModel = $record->getField('name'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Contacts' => ['phone' => 'WORK', 'mobile' => 'CELL'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \Sabre\VObject\Component\VCard Card object. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete card by crm id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uri' => $uri,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $record
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setValuesForRecord(\Vtiger_Record_Model $record): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->NOTE) && ($fieldModel = $record->getField('description'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Mail fields. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $uri
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addressbookid' => $addressBookId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
public static function loadFromContent(string $content, ?\Vtiger_Record_Model $recordModel = null, ?string $uid = null): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function deleteByCrmId(int $id): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('birthday', date('Y-m-d', strtotime($this->card->BDAY)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('last_name', $fieldModel->getDBValue(\App\Purifier::purify($head[0])));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->BDAY) && $record->getField('birth_date')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Phone fields. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $record;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model|null $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function addChange(int $addressBookId, string $uri, int $operation): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set values for record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
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')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('OSSEmployees' === $moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \Vtiger_Record_Model Record model. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $addressBookId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->TITLE) && ($fieldModel = $record->getField('jobtitle'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('description', $fieldModel->getDBValue(\App\Purifier::purify((string) $this->card->NOTE)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set($fieldModel->getFieldName(), $lead->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('assigned_user_id', $this->user->get('id'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$types[] = 'WORK';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usedTypes = array_merge($usedTypes, $types);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($type, $types)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $gender
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'M':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$salutation = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $salutation;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->TEL) && ($fieldModel = $this->record->getField($key))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($type, $types)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->card->EMAIL) && ($fieldModel = $this->record->getField($key))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const MAIL_FIELDS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setValuesForCreateRecord(\Vtiger_Record_Model $record): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getVCard(): \Sabre\VObject\Component\VCard
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Contacts' === $record->getModuleName() && isset($this->card->ORG)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lead->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add change to address books .
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->insert('dav_addressbookchanges', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (self::PHONE_FIELDS[$moduleName] as $key => $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAddressBook(int $id)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$details = $fieldModel->getUITypeModel()->getPhoneDetails($orgPhone, $country);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (isset($this->card->FN)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$orgPhone = $details['number'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($head[0]) && ($fieldModel = $record->getField('lastname'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $record
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $addressFromVCard
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->card->EMAIL as $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$types = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel = $record->getField($fieldName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = current($record->getModule()->getReferenceFieldsForModule('Leads'));
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
$country = \App\Fields\Country::getCountryCode(\App\User::getUserModel($userId)->getDetail('sync_carddav_default_country'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = strtoupper($type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($e->parameters() as $p) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cardType = explode(',', $p->getValue());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$types[] = strtoupper(array_reverse($cardType)[0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getCardGender(string $gender): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function parsePhone(): void
- Exclude checks
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'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usedTypes = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $this->record->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse email.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usedTypes = array_merge($usedTypes, $types);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsForJoin[] = $address[$val];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel = $lead->getField('company')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($t->parameters() as $p) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set($fieldName, $fieldModel->getDBValue(implode(' ', $fieldsForJoin)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $record
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lead->set('assigned_user_id', $this->user->get('id'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lead->set('leadstatus', 'PLL_PENDING');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($userId = $this->user ? $this->user->getId() : null) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = strtoupper($type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cardType = explode(',', $p->getValue());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'F':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setValuesForRecord($record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function parseMail(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$types[] = 'WORK';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($key !== $details['fieldName']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (self::MAIL_FIELDS[$moduleName] as $key => $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->card->ADR as $property) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsForJoin = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'street' => \App\Purifier::purify(trim($addressFromVCard[2])),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postOfficeBox' => \App\Purifier::purify($addressFromVCard[0]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get type of address.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = $parameter->jsonSerialize()[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usedTypes = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$address = $this->convertAddress($property->getParts());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Convert address.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$types && !\in_array('WORK', $usedTypes)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => \App\Fields\Country::findCountryName(\App\Purifier::purify($addressFromVCard[6])),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postCode' => \App\Purifier::purify($addressFromVCard[5]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$typeOfAddress = $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lead->set('company', $fieldModel->getDBValue((string) $this->card->ORG));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->card->TEL as $t) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $this->record->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get card gender).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($gender) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$salutation = 'Mr.';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (static::ADDRESS_MAPPING[$moduleName][$typeOfAddress] ?? [] as $fieldName => $fieldsInVCard) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse phone.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$types[] = strtoupper($cardType[0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$types && !\in_array('WORK', $usedTypes)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->record->set($key, $fieldModel->getDBValue(\App\Purifier::purify($e->getValue())));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$salutation = 'Mrs.';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set record address.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($typeOfAddress = $this->getTypeOfAddress($property)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('WORK' === $type || 'HOME' == $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set values for create record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$types = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$orgPhone = \App\Purifier::purify($t->getValue());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->record->set($details['fieldName'], $details['number']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldsInVCard as $val) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $typeOfAddress;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function convertAddress(array $addressFromVCard): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($property->parameters as $parameter) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getTypeOfAddress(\Sabre\VObject\Property $property): ?string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$typeOfAddress = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lead = \Vtiger_Record_Model::getCleanInstance('Leads');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$country = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($orgPhone && 'phone' === $fieldModel->getFieldDataType()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->record->set($key, $fieldModel->getDBValue($orgPhone));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setRecordAddress(string $moduleName, \Vtiger_Record_Model $record): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'state' => \App\Purifier::purify($addressFromVCard[4]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => \App\Purifier::purify($addressFromVCard[3]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'localNumber' => \App\Purifier::purify($addressFromVCard[1]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $property
- Exclude checks