Function getFieldValue
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
public function getFieldValue(string $magentoFieldName, ?string $crmFieldName = null)
{
$parsedFieldName = $crmFieldName ?? $this->getFieldNameCrm($magentoFieldName);
$methodName = 'getCrm' . \ucfirst($parsedFieldName);
$fieldLevels = explode('|', $magentoFieldName);
- 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 getAddressFieldValue
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
{
$methodName = 'getCrm' . \ucfirst($fieldNameCrm);
if (!empty($fieldParsed = $this->getAddressDataByType($type))) {
if (\method_exists($this, $methodName)) {
- 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 Base has an overall complexity of 67 which is very high. The configured complexity threshold is 50. Open
abstract class Base
{
/**
* Map module name.
*
- Exclude checks
File Base.php
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Abstract base map file.
*
Method getFieldValue
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFieldValue(string $magentoFieldName, ?string $crmFieldName = null)
{
$parsedFieldName = $crmFieldName ?? $this->getFieldNameCrm($magentoFieldName);
$methodName = 'getCrm' . \ucfirst($parsedFieldName);
$fieldLevels = explode('|', $magentoFieldName);
Method getAddressFieldValue
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
{
$methodName = 'getCrm' . \ucfirst($fieldNameCrm);
if (!empty($fieldParsed = $this->getAddressDataByType($type))) {
if (\method_exists($this, $methodName)) {
Function getCustomAttributeValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getCustomAttributeValue(string $name)
{
$value = '';
$customAttributes = $this->data['custom_attributes'];
if (!empty($customAttributes)) {
- 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 parsePhone
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function parsePhone(string $fieldName, array $parsedData): array
{
if (\App\Config::main('phoneFieldAdvancedVerification', false)) {
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
try {
- 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 getFieldValue() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10. Open
public function getFieldValue(string $magentoFieldName, ?string $crmFieldName = null)
{
$parsedFieldName = $crmFieldName ?? $this->getFieldNameCrm($magentoFieldName);
$methodName = 'getCrm' . \ucfirst($parsedFieldName);
$fieldLevels = explode('|', $magentoFieldName);
- 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 getAddressFieldValue() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
{
$methodName = 'getCrm' . \ucfirst($fieldNameCrm);
if (!empty($fieldParsed = $this->getAddressDataByType($type))) {
if (\method_exists($this, $methodName)) {
- 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 38 to the 15 allowed. Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
- 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 48 to the 15 allowed. Open
public function getFieldValue(string $magentoFieldName, ?string $crmFieldName = null)
- 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
Avoid using undefined variables such as '$fieldName' which will lead to PHP notices. Open
$name = $fieldLevel ?? $fieldName;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The method getFields has a boolean flag argument $onEdit, which is a certain sign of a Single Responsibility Principle violation. Open
public function getFields(bool $onEdit = false): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '483', column '25'). Open
$queryGenerator = new \App\QueryGenerator($moduleName);
- 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
The method getDataCrm has a boolean flag argument $onEdit, which is a certain sign of a Single Responsibility Principle violation. Open
public function getDataCrm(bool $onEdit = false): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldInstance = \Vtiger_Module_Model::getInstance($this->moduleName)->getFieldByName($parsedFieldName);
$fieldInstance->setNoRolePicklistValues([trim($fieldParsedValue)]);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Fields\Date' in method 'getFieldValue'. Open
$fieldParsed = \App\Fields\Date::formatToDb($fieldParsed, true);
- 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\Cache' in method 'getCrmId'. Open
return \App\Cache::staticGet('CrmIdByMagentoId' . $moduleName, $magentoId);
- 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\DateTime' in method 'getFieldValue'. Open
$fieldParsed = \App\Fields\DateTime::formatToDb($fieldParsed, true);
- 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
The method getAddressFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldParsed = '';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldParsed = $this->{$methodName}();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Cache' in method 'getCrmId'. Open
\App\Cache::staticSave('CrmIdByMagentoId' . $moduleName, $magentoId, $crmId);
- 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
The method getAddressFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldParsed = \is_array($fieldParsed) ? null : $fieldParsed;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method parsePhone uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parsedData[$fieldName . '_extra'] = trim($parsedData[$fieldName]);
unset($parsedData[$fieldName]);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid assigning values to variables in if clauses and the like (line '396', column '14'). Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
{
$methodName = 'getCrm' . \ucfirst($fieldNameCrm);
if (!empty($fieldParsed = $this->getAddressDataByType($type))) {
if (\method_exists($this, $methodName)) {
- 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
The method getAddressFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldParsed = $fieldParsed[$fieldName] ?? '';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Cache' in method 'getCrmId'. Open
if (\App\Cache::staticHas('CrmIdByMagentoId' . $moduleName, $magentoId)) {
- 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
The method getFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldParsed = !\is_array($fieldParsed) ? $fieldParsed : null;
if (null === $fieldParsed) {
$name = $fieldLevel ?? $fieldName;
\App\Log::info("No value in mapping|CRM: $parsedFieldName|Magento: $name|" . PHP_EOL . print_r($fieldParsedValue, true), 'Updates');
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Config' in method 'parsePhone'. Open
if (\App\Config::main('phoneFieldAdvancedVerification', false)) {
- 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 '\libphonenumber\PhoneNumberUtil' in method 'parsePhone'. Open
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
- 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 '401', column '10'). Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
{
$methodName = 'getCrm' . \ucfirst($fieldNameCrm);
if (!empty($fieldParsed = $this->getAddressDataByType($type))) {
if (\method_exists($this, $methodName)) {
- 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
The method getAddressFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($elements !== $level + 1) {
$fieldParsed = '';
}
break;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Log' in method 'getFieldValue'. Open
\App\Log::info("No value in mapping (map)|name: $parsedFieldName|value: $fieldParsedValue", 'Updates');
- 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
The method getFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$elements = \count($fieldLevels);
foreach ($fieldLevels as $level => $fieldLevel) {
if (isset($fieldParsed[$fieldLevel])) {
$fieldParsed = $fieldParsed[$fieldLevel];
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($elements !== $level + 1) {
$fieldParsed = '';
}
break;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldParsed = $fieldParsed[$magentoFieldName] ?? '';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Fields\Country' in method 'getFieldValue'. Open
$fieldParsed = \App\Fields\Country::getCountryName($fieldParsed);
- 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
The method getAddressFieldValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldLevels = explode('|', $fieldName);
if (($elements = \count($fieldLevels)) > 1) {
foreach ($fieldLevels as $level => $fieldLevel) {
if (isset($fieldParsed[$fieldLevel])) {
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Fields\Country' in method 'getAddressFieldValue'. Open
$fieldParsed = \App\Fields\Country::getCountryName($fieldParsed);
- 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\Log' in method 'getFieldValue'. Open
\App\Log::info("No value in mapping|CRM: $parsedFieldName|Magento: $name|" . PHP_EOL . print_r($fieldParsedValue, true), 'Updates');
- 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 "telephone" 4 times. Open
'phone_a' => 'telephone',
- 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" 4 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.
Remove the unused function parameter "$onEdit". Open
public function getFields(bool $onEdit = false): array
- Read upRead up
- Exclude checks
Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.
Noncompliant Code Example
function doSomething($a, $b) { // "$a" is unused return compute($b); }
Compliant Solution
function doSomething($b) { return compute($b); }
Exceptions
Functions in classes that override a class or implement interfaces are ignored.
class C extends B { function doSomething($a, $b) { // no issue reported on $b compute($a); } }
See
- MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
- MISRA C:2012, 2.7 - There should be no unused parameters in functions
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
- CERT, MSC12-CPP. - Detect and remove code that has no effect
Define a constant instead of duplicating this literal "CrmIdByMagentoId" 3 times. Open
if (\App\Cache::staticHas('CrmIdByMagentoId' . $moduleName, $magentoId)) {
- 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.
Add a "case default" clause to this "switch" statement. Open
switch (static::$fieldsType[$parsedFieldName]) {
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Add a "case default" clause to this "switch" statement. Open
switch (static::$fieldsType[$fieldNameCrm]) {
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Rename "$data" which has the same name as the field declared at line 69. Open
$data = [];
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Rename "$fieldsType" which has the same name as the field declared at line 52. Open
$fieldsType = $type . 'Fields';
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Avoid unused parameters such as '$onEdit'. Open
public function getFields(bool $onEdit = false): array
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$fieldName'. Open
$name = $fieldLevel ?? $fieldName;
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Reference to constant INTERNATIONAL
from undeclared class \libphonenumber\PhoneNumberFormat
Open
$international = $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);
- Exclude checks
Call to method setStateCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setStateCondition('All');
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields(['id'])->permissions = false;
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info("No value in mapping|CRM: $parsedFieldName|Magento: $name|" . PHP_EOL . print_r($fieldParsedValue, true), 'Updates');
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = new \App\QueryGenerator($moduleName);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticGet()
takes string
defined at /code/app/Cache.php:128
Open
return \App\Cache::staticGet('CrmIdByMagentoId' . $moduleName, $magentoId);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticHas()
takes string
defined at /code/app/Cache.php:141
Open
if (\App\Cache::staticHas('CrmIdByMagentoId' . $moduleName, $magentoId)) {
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info("No value in mapping (map)|name: $parsedFieldName|value: $fieldParsedValue", 'Updates');
- Exclude checks
Catching undeclared class \libphonenumber\NumberParseException
Open
} catch (\libphonenumber\NumberParseException $e) {
- Exclude checks
Variable $fieldName
is undeclared Open
$name = $fieldLevel ?? $fieldName;
- Exclude checks
Call to method getInstance
from undeclared class \libphonenumber\PhoneNumberUtil
Open
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
- Exclude checks
Call to method addCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addCondition('magento_server_id', $this->synchronizer->config->get('id'), 'e');
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$crmId = $queryGenerator->createQuery()->scalar() ?: 0;
- Exclude checks
Call to method addCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addCondition('magento_id', $magentoId, 'e');
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticSave()
takes string
defined at /code/app/Cache.php:156
Open
\App\Cache::staticSave('CrmIdByMagentoId' . $moduleName, $magentoId, $crmId);
- 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
* Mapped fields type.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $dataCrm = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel1a' => 'country_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'last_name_a' => 'lastname',
- 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
* Data from Magento.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'first_name_a' => 'firstname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vat_id_a' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $shippingFields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->dataCrm[$name] = !empty($value) ? $value : $this->getFieldValue($name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get field value from Magento.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $magentoFieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch (static::$fieldsType[$parsedFieldName]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $fieldParsed) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::info("No value in mapping (map)|name: $parsedFieldName|value: $fieldParsedValue", 'Updates');
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
* The file is part of the paid functionality. Using the file is allowed only after purchasing a subscription. File modification allowed only with the consent of the system producer.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var \App\Integrations\Magento\Synchronizer\Base
- 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
'buildingnumbera' => 'street|1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Data from YetiForce.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel2b' => 'region|region',
- 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
'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
'first_name_b' => 'firstname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFields(bool $onEdit = false): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'2' => 'PLL_WOMAN',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$additionalFieldsCrm;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setDataCrm(array $data): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->dataCrm = $data;
- 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
$methodName = 'getCrm' . \ucfirst($parsedFieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldLevels = explode('|', $magentoFieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldLevels as $level => $fieldLevel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $this->getCustomAttributeValue(end($fieldLevels));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $fieldParsed[$fieldLevel];
- 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
$fieldParsed = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null !== $fieldParsed && isset(static::$fieldsType[$parsedFieldName])) {
- 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
protected $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
public $data = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $billingFields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel2a' => 'region|region',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone' => 'telephone',
- 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_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'last_name_b' => 'lastname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mobile' => 'fax',
- 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 mixed|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $onEdit
- 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 additional YetiForce fields list.
- 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 getFieldValue(string $magentoFieldName, ?string $crmFieldName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = static::${$parsedFieldName}[$fieldParsed] ?? 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
'salutationtype' => 'map',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vat_id_b' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone' => 'telephone',
- 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->synchronizer = $synchronizer;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_flip(static::$mappedFields)[$name] ?? $name;
- 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 getAdditionalFieldsCrm(): 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
$this->dataCrm[$fieldCrm] = $this->getFieldValue($field, $fieldCrm) ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($fieldParsed[$fieldLevel])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($elements !== $level + 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Mapped billing fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone_a' => 'telephone',
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $data
- 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
* Map module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var 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
* @var 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
foreach ($this->getAdditionalFieldsCrm() as $name => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array|mixed
- 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
$fieldParsedValue = $fieldParsed;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var 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
'addresslevel5a' => 'city',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_b' => '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
];
- 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 array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$mappedFields;
- 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 ($this->getFields($onEdit) as $fieldCrm => $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$onEdit) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('custom_attributes' === $fieldLevels[0]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $fieldParsed[$magentoFieldName] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Mapped fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $fieldsType = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'1' => 'Mr.',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'2' => 'Mrs.',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'1' => 'PLL_MAN',
- 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 __construct(\App\Integrations\Magento\Synchronizer\Base $synchronizer)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFieldNameCrm(string $name)
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setData(array $data): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDataCrm(bool $onEdit = false): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$elements = \count($fieldLevels);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
\App\Log::info("No value in mapping (map)|name: $parsedFieldName|value: $fieldParsedValue", 'Updates');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $synchronizer;
- 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
* Mapped shipping fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'buildingnumberb' => 'street|1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone_b' => 'telephone',
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string[]
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_a' => 'email',
- 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
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Contacts_gender map.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $onEdit
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->dataCrm;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $crmFieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\count($fieldLevels) > 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'map':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Fields which are not exist in Magento but needed in YetiForce.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Fields default value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mobile' => 'fax',
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $this->data;
- 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
* Synchronizer.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $mappedFields = [];
- 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
* @var string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'company_name_a' => 'company',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addresslevel8b' => 'street|0',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Contacts_gender map.
- 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 \App\Integrations\Magento\Synchronizer\Base $synchronizer
- 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 fields list.
- 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
*/
- 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
public static $fieldsDefaultValue = [];
- 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
'addresslevel8a' => 'street|0',
- 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 $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
* Set data YetiForce.
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $salutationtype = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Return YetiForce field name.
- 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 parsed data in YetiForce format.
- 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 (!\method_exists($this, $methodName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $additionalFieldsCrm = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'gender' => 'map',
- 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
'company_name_b' => '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
/**
- 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
$parsedFieldName = $crmFieldName ?? $this->getFieldNameCrm($magentoFieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mapAndAddNew':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'datetime':
- 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
return $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse phone number.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$international = $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$international = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($parsedData[$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
case 'implode':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = !\is_array($fieldParsed) ? $fieldParsed : 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
public function parsePhone(string $fieldName, array $parsedData): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Return address data.
- 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
$fieldParsed = $this->{$methodName}();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::${$parsedFieldName}[$fieldParsed])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = \App\Fields\Country::getCountryName($fieldParsed);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = '';
- 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
if (($elements = \count($fieldLevels)) > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = static::${$parsedFieldName}[$fieldParsed] ?? $fieldParsed;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance = \Vtiger_Module_Model::getInstance($this->moduleName)->getFieldByName($parsedFieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = \App\Fields\DateTime::formatToDb($fieldParsed, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \is_array($fieldParsed) ? $fieldParsed : trim($fieldParsed);
- 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 ($international) {
- 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 ($elements !== $level + 1) {
- 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
* Get custom attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCustomAttributeValue(string $name)
- 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
$addressData[$fieldNameCrm] = $this->getAddressFieldValue($type, $fieldNameCrm, $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
return $fields ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->setNoRolePicklistValues([trim($fieldParsedValue)]);
- 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 ($name === $customAttribute['attribute_code']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- 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 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $parsedData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$addressData = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\method_exists($this, $methodName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = implode(', ', $fieldParsed);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::info("No value in mapping|CRM: $parsedFieldName|Magento: $name|" . PHP_EOL . print_r($fieldParsedValue, true), 'Updates');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $name
- 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 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
} catch (\libphonenumber\NumberParseException $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parsedData[$fieldName . '_extra'] = trim($parsedData[$fieldName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null !== $fieldParsed && isset(static::$fieldsType[$fieldNameCrm])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'date':
- 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 mixed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parsedData[$fieldName] = $international;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $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 $fieldNameCrm
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array|mixed
- 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
$methodName = 'getCrm' . \ucfirst($fieldNameCrm);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldLevels = explode('|', $fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($fieldParsed[$fieldLevel])) {
- 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
}
- 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 (\App\Config::main('phoneFieldAdvancedVerification', false)) {
- 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 array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($fieldParsed = $this->getAddressDataByType($type))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $fieldParsed[$fieldName] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch (static::$fieldsType[$fieldNameCrm]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'implode':
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$fieldInstance = \Vtiger_Module_Model::getInstance($this->moduleName)->getFieldByName($parsedFieldName);
- 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
$name = $fieldLevel ?? $fieldName;
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
\App\Log::info("No value in mapping|CRM: $parsedFieldName|Magento: $name|" . PHP_EOL . print_r($fieldParsedValue, true), 'Updates');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $customAttribute['value'];
- 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
Line exceeds 120 characters; contains 121 characters Open
$international = $phoneUtil->format($swissNumberProto, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);
- 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
* @param string $fieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getAddressFieldValue(string $type, string $fieldNameCrm, string $fieldName)
- 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 'parentRecord':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $this->getCrmId((int) $fieldParsed);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $fieldParsed) {
- 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
$fieldParsed = $this->{$methodName}();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = static::${$fieldsType};
- 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 '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
foreach ($customAttributes as $customAttribute) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->getAddressFieldsCrm($type) as $fieldNameCrm => $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Return address fields crm.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get address field value from Magento.
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customAttributes = $this->data['custom_attributes'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$swissNumberProto = $phoneUtil->parse(trim($parsedData[$fieldName]));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getAddressDataCrm(string $type): 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
public function getAddressFieldsCrm(string $type): 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
return $addressData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsType = $type . 'Fields';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty(static::${$fieldsType})) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = $fieldParsed[$fieldLevel];
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $data ?? current($this->data['addresses']) ?? [];
- 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
$crmId = $queryGenerator->createQuery()->scalar() ?: 0;
- 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
$fieldParsed = \App\Fields\Date::formatToDb($fieldParsed, true);
- 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 (!empty($customAttributes)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $parsedData
- 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 ($fieldLevels as $level => $fieldLevel) {
- 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
$addressName = 'default_' . $addressType;
- 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
$queryGenerator->addCondition('magento_id', $magentoId, 'e');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = \App\Fields\Country::getCountryName($fieldParsed);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldParsed = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->data[$addressName]) && $address['id'] == $this->data[$addressName]) {
- 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
$queryGenerator->setStateCondition('All');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticSave('CrmIdByMagentoId' . $moduleName, $magentoId, $crmId);
- 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 birthday.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCrmId(int $magentoId, ?string $moduleName = null): int
- 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 (!$dob || '0000-00-00' === $dob) {
- 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
* @return int
- 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
$fieldParsed = implode(', ', $fieldParsed);
- 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
case 'country':
- 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
return trim($fieldParsed);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get given type address data.
- 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 null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get crm id by magento id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Cache::staticHas('CrmIdByMagentoId' . $moduleName, $magentoId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getAddressDataByType(string $addressType)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return date('Y-m-d', strtotime($dob));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = new \App\QueryGenerator($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $crmId;
- 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
public function getCrmBirthday()
- 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
$fieldParsed = \is_array($fieldParsed) ? null : $fieldParsed;
- 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
$dob = $this->data['dob'] ?? $this->data['customer_dob'] ?? false;
- 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 (empty($moduleName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setFields(['id'])->permissions = false;
- 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->data['addresses'] as $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
}
- 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 $addressType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $address;
- 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
$moduleName = $this->moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Cache::staticGet('CrmIdByMagentoId' . $moduleName, $magentoId);
- 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
} else {
- 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 $magentoId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addCondition('magento_server_id', $this->synchronizer->config->get('id'), 'e');
- Exclude checks