Function import
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function import(): bool
{
$allChecked = false;
try {
if ($invoices = $this->getInvoicesFromApi()) {
- 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 import
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function import(): bool
{
$allChecked = false;
try {
if ($invoices = $this->getInvoicesFromApi()) {
The method import() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function import(): bool
{
$allChecked = false;
try {
if ($invoices = $this->getInvoicesFromApi()) {
- 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 34 to the 15 allowed. Open
public function import(): bool
- 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 '$searchCriteria' which will lead to PHP notices. Open
$searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][value]=' . $this->config->get('store_id');
- 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
Avoid using undefined variables such as '$searchCriteria' which will lead to PHP notices. Open
$searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][conditionType]=eq';
- 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
Avoid using undefined variables such as '$searchCriteria' which will lead to PHP notices. Open
$searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][field]=store_id';
- 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
Avoid using undefined variables such as '$searchCriteria' which will lead to PHP notices. Open
$searchCriteria[] = parent::getSearchCriteria($pageSize);
- 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
Avoid using undefined variables such as '$searchCriteria' which will lead to PHP notices. Open
return implode('&', $searchCriteria);
- 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
Avoid using static access to class '\App\Log' in method 'import'. Open
\App\Log::error('Error during import invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- 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 'createInvoiceInCrm'. Open
\App\Log::error('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');
- 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 '\Vtiger_Record_Model' in method 'createInvoiceInCrm'. Open
$recordModel = \Vtiger_Record_Model::getCleanInstance('FInvoice');
- 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 '45', column '8'). Open
public function import(): bool
{
$allChecked = false;
try {
if ($invoices = $this->getInvoicesFromApi()) {
- 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\Log' in method 'import'. Open
\App\Log::error('Empty map invoice details', 'Integrations/Magento');
- 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 createInvoiceInCrm uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->log('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']');
\App\Log::error('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');
}
- 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 'import'. Open
\App\Log::error('Empty invoice details', 'Integrations/Magento');
- 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 import uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$customer = $this->getFromApi('customers', $invoice['customer_id']);
$customerClassName = $this->config->get('customer_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Customer';
$customerMapModel = new $customerClassName($this);
$customerMapModel->setData($customer);
- 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 'import'. Open
\App\Log::error('Error during saving invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- 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 import uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$allChecked = true;
}
- 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 import uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
\App\Log::error('Empty map invoice details', 'Integrations/Magento');
}
- 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\Json' in method 'getInvoicesFromApi'. Open
$data = \App\Json::decode($this->connector->request('GET', $this->config->get('store_code') . '/V1/invoices?' . $this->getSearchCriteria($this->config->get('invoices_limit'))));
- 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 'import'. Open
\App\Cache::staticSave('CrmIdByMagentoIdSSingleOrders', $invoice['entity_id'], $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
Define a constant instead of duplicating this literal "customer_id" 4 times. Open
$invoice['customer_id'] = $order['customer_id'] ?? '';
- 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 "Integrations/Magento" 5 times. Open
\App\Log::error('Empty invoice details', 'Integrations/Magento');
- 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 "start_date" 3 times. Open
if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {
- 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 "entity_id" 6 times. Open
if (!$mapModel->getCrmId($invoice['entity_id'])) {
- 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 "invoice" 5 times. Open
$this->lastScan = $this->config->getLastScan('invoice');
- 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.
Avoid unused parameters such as '$ids'. Open
public function getInvoicesFromApi(array $ids = []): 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
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('Empty invoice details', 'Integrations/Magento');
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('Empty map invoice details', 'Integrations/Magento');
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('Error during saving invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('Error during import invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');
- Exclude checks
Variable $searchCriteria
was undeclared, but array fields are being added to it. Open
$searchCriteria[] = parent::getSearchCriteria($pageSize);
- Exclude checks
Similar blocks of code found in 4 locations. Consider refactoring. Open
public function process()
{
$this->lastScan = $this->config->getLastScan('invoice');
if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {
$this->config->setScan('invoice');
- 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 126.
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
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
* Import invoices 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
$invoice['payment'] = $order['payment'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customer = $this->getFromApi('customers', $invoice['customer_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
$order = $this->getFromApi('orders', $invoice['order_id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$invoice['customer_id'] = $order['customer_id'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->import()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->config->setScan('invoice');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- 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
$invoice['extension_attributes'] = $order['extension_attributes'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataCrm['magento_id'] = $invoice['entity_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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($invoices as $id => $invoice) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataCrm['accountid'] = $this->syncAccount($dataCrm);
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataCrm['ssingleordersid'] = $mapModel->getCrmId($invoice['order_id'], 'SSingleOrders');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 156 characters Open
$customerClassName = $this->config->get('customer_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Customer';
- Exclude checks
Spaces must 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 ($this->saveInventoryCrm($recordModel, $mapModel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Method to get invoices form Magento.
- 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 getInvoicesFromApi(array $ids = []): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = \App\Json::decode($this->connector->request('GET', $this->config->get('store_code') . '/V1/invoices?' . $this->getSearchCriteria($this->config->get('invoices_limit'))));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->lastScan = $this->config->getLastScan('invoice');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->config->setEndScan('invoice', $this->lastScan['start_date']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$className = $this->config->get('invoice_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Invoice';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$invoice['billing_address'] = $order['billing_address'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($dataCrm) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mapModel->setDataCrm($dataCrm);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error('Empty map invoice details', 'Integrations/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
return $allChecked;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customerMapModel = new $customerClassName($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customerMapModel->setData($customer);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customerDataCrm = $customerMapModel->getDataCrm();
- Exclude checks
Spaces must 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
\App\Log::error('Error during saving invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
$this->log('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($data['items'] as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$items[$item['entity_id']] = $item;
- Exclude checks
Spaces must 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 bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmId = $this->createInvoiceInCrm($mapModel);
- Exclude checks
Spaces must 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 ($mapModel->dataCrm as $key => $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
if (!$mapModel->getCrmId($invoice['entity_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
$this->config->setScan('invoice', 'id', $id);
- 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
$this->log('Import invoices', $ex);
- Exclude checks
Spaces must 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 getSearchCriteria(int $pageSize = 10): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][conditionType]=eq';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return implode('&', $searchCriteria);
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$dataCrm['ssingleordersid'] = $mapModel->getCrmId($invoice['order_id'], 'SSingleOrders');
- 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
\App\Log::error('Error during import invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- 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
$customerClassName = $this->config->get('customer_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Customer';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataCrm['accountid'] = $this->syncAccount($customerDataCrm);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Method to save invoice to 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
if (isset($fields[$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
return $recordModel->getId();
- Exclude checks
Spaces must 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 $items;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allChecked = false;
- 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
\App\Log::error('Empty invoice details', 'Integrations/Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mapModel = new $className($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mapModel->setData($invoice);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Throwable $ex) {
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
\App\Log::error('Error during saving invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 185 characters Open
$data = \App\Json::decode($this->connector->request('GET', $this->config->get('store_code') . '/V1/invoices?' . $this->getSearchCriteria($this->config->get('invoices_limit'))));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($data['items'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set($key, $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
} catch (\Throwable $ex) {
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
\App\Log::error('Error during import invoice: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/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
$searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][value]=' . $this->config->get('store_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
$dataCrm = $mapModel->getDataCrm();
- Exclude checks
Line exceeds 120 characters; contains 196 characters Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allChecked = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Vtiger_Record_Model::getCleanInstance('FInvoice');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must 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
$items = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][field]=store_id';
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->lastScan = $this->config->getLastScan('invoice');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function import(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($invoice)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = $this->config->get('invoice_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Invoice';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticSave('CrmIdByMagentoIdSSingleOrders', $invoice['entity_id'], $crmId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->log('Saving invoice', $ex);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = $recordModel->getModule()->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->log('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
\App\Log::error('Skipped saving record, problem with inventory products | invoice id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($invoices = $this->getInvoicesFromApi()) {
- 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
if (empty($invoice['customer_id'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createInvoiceInCrm(Maps\Inventory $mapModel): int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Maps\Inventory $mapModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('magento_server_id', $this->config->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
$searchCriteria[] = parent::getSearchCriteria($pageSize);
- Exclude checks
Spaces must 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 $ids
- Exclude checks
No space found after comma in function call Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
No space found after comma in function call Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
No space found after comma in function call Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
No space found after comma in function call Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
No space found after comma in function call Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks
No space found after comma in function call Open
unset($dataCrm['birthday'],$dataCrm['leadsource'],$dataCrm['mobile'],$dataCrm['mobile_extra'],$dataCrm['phone'],$dataCrm['phone_extra'],$dataCrm['salutationtype']);
- Exclude checks