YetiForceCompany/YetiForceCRM

View on GitHub
app/Integrations/Magento/Synchronizer/Order.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Function import has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    public function import(): bool
    {
        $allChecked = false;
        try {
            if ($orders = $this->getOrdersFromApi()) {
Severity: Minor
Found in app/Integrations/Magento/Synchronizer/Order.php - About 4 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Method import has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function import(): bool
    {
        $allChecked = false;
        try {
            if ($orders = $this->getOrdersFromApi()) {
Severity: Major
Found in app/Integrations/Magento/Synchronizer/Order.php - About 2 hrs to fix

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

        public function process()
        {
            $this->lastScan = $this->config->getLastScan('order');
            if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {
                $this->config->setScan('order');
    Severity: Minor
    Found in app/Integrations/Magento/Synchronizer/Order.php - About 45 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        public function createOrderInCrm(Maps\Inventory $mapModel)
        {
            $recordModel = \Vtiger_Record_Model::getCleanInstance('SSingleOrders');
            if ($this->config->get('storage_id')) {
                $recordModel->set('istorageaddressid', $this->config->get('storage_id'));
    Severity: Minor
    Found in app/Integrations/Magento/Synchronizer/Order.php - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        public function import(): bool
        {
            $allChecked = false;
            try {
                if ($orders = $this->getOrdersFromApi()) {

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

        public function import(): bool

    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][field]=store_id';

    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';

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

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

    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][value]=' . $this->config->get('store_id');

    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

    Missing class import via use statement (line '224', column '24').
    Open

            $query->andWhere(new \yii\db\Expression('modifiedtime <> createdtime'));

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Missing class import via use statement (line '256', column '14').
    Open

                throw new \Exception('No status mapping (in self::$statusForMagento): ' . $mapModel->dataCrm['ssingleorders_status']);

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Missing class import via use statement (line '219', column '26').
    Open

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

    MissingImport

    Since: 2.7.0

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

    Example

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

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

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

        public function import(): bool
        {
            $allChecked = false;
            try {
                if ($orders = $this->getOrdersFromApi()) {

    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('Error during saving order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

    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', $order['entity_id'], $crmId);

    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 '71', column '12').
    Open

        public function import(): bool
        {
            $allChecked = false;
            try {
                if ($orders = $this->getOrdersFromApi()) {

    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 order details', 'Integrations/Magento');

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

            $recordModel = \Vtiger_Record_Model::getCleanInstance('SSingleOrders');

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

                            \App\Log::error('Empty map order details', 'Integrations/Magento');

    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', $order['customer_id']);
                                        $customerClassName = $this->config->get('customer_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Customer';
                                        $customerMapModel = new $customerClassName($this);
                                        $customerMapModel->setData($customer);

    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 {
                    $allChecked = true;
                }

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

            $data = \App\Json::decode($this->connector->request('GET', $this->config->get('store_code') . '/V1/orders?' . $this->getSearchCriteria($this->config->get('orders_limit'))));

    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 {
                            \App\Log::error('Empty map order details', 'Integrations/Magento');
                        }

    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 {
                                    $parentOrder = $dataCrm['parent_id'];
                                    if (empty($order['customer_id'])) {
                                        $dataCrm['parent_id'] = $this->syncAccount($dataCrm);
                                        $dataCrm['contactid'] = $this->syncContact($dataCrm);

    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 import order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

                \App\Log::error('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');

    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 createOrderInCrm 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 | order id: [' . $mapModel->data['entity_id'] . ']');
                \App\Log::error('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');
            }

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

                \App\Log::error('Error during export order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

        public function updateOrderInMagento(array $row): void
        {
            $className = $this->config->get('order_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Order';
            $mapModel = new $className($this);
            $mapModel->setDataCrm($row);

    IfStatementAssignment

    Since: 2.7.0

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

    Example

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

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

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

            $recordModel = \Vtiger_Record_Model::getInstanceById($id, 'SSingleOrders');

    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 updateOrderInMagento 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("No status mapping for: crmid: {$row['id']} | magento_id: {$row['magento_id']} | status: {$row['ssingleorders_status']}", 'Integrations/Magento');
                throw new \Exception('No status mapping (in self::$statusForMagento): ' . $mapModel->dataCrm['ssingleorders_status']);
            }

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

                \App\Log::error("No status mapping for: crmid: {$row['id']} | magento_id: {$row['magento_id']} | status: {$row['ssingleorders_status']}", 'Integrations/Magento');

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

            if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {

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

            $this->lastScan = $this->config->getLastScan('order');

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

                                    $parentOrder = $dataCrm['parent_id'];

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

            if (!$this->lastScan['start_date'] || (0 === (int) $this->lastScan['id'] && $this->lastScan['start_date'] === $this->lastScan['end_date'])) {

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

                                    $dataCrm['magento_id'] = $order['entity_id'];

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

            $recordModel = \Vtiger_Record_Model::getCleanInstance('SSingleOrders');

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

            'ssingleorders_status', 'status_magento',

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

                            \App\Log::error('Empty order details', 'Integrations/Magento');

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

            $this->lastScan = $this->config->getLastScan('crm_order');

    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 and throw a dedicated exception instead of using a generic one.
    Open

                throw new \Exception('No status mapping (in self::$statusForMagento): ' . $mapModel->dataCrm['ssingleorders_status']);

    If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

    Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

    Noncompliant Code Example

    throw new Exception();  // Noncompliant
    

    Compliant Solution

    throw new InvalidArgumentException();
    // or
    throw new UnexpectedValueException();
    

    See

    Define a constant instead of duplicating this literal "entity_id" 6 times.
    Open

                                if ($crmId = $mapModel->getCrmId($order['entity_id'])) {

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

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

            $queryGenerator->setFields(['id', 'magento_id', 'ssingleorders_status', 'subject'])->permissions = false;

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

            $query = $queryGenerator->createQuery();

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

            $queryGenerator->setStateCondition('All');

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

                                \App\Log::error('Error during saving order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

            $queryGenerator->addCondition('magento_server_id', $this->config->get('id'), 'e');

    Variable $searchCriteria was undeclared, but array fields are being added to it.
    Open

            $searchCriteria[] = parent::getSearchCriteria($pageSize);

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

                            \App\Log::error('Empty map order details', 'Integrations/Magento');

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

                \App\Log::error('Error during export order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

    Call to method __construct from undeclared class \yii\db\Expression
    Open

            $query->andWhere(new \yii\db\Expression('modifiedtime <> createdtime'));

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

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

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

                            \App\Log::error('Empty order details', 'Integrations/Magento');

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

                \App\Log::error('Error during import order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

                \App\Log::error('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');

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

                \App\Log::error("No status mapping for: crmid: {$row['id']} | magento_id: {$row['magento_id']} | status: {$row['ssingleorders_status']}", 'Integrations/Magento');

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

        public function getOrdersFromApi(): array
        {
            $items = [];
            $data = \App\Json::decode($this->connector->request('GET', $this->config->get('store_code') . '/V1/orders?' . $this->getSearchCriteria($this->config->get('orders_limit'))));
            if (!empty($data['items'])) {
    Severity: Major
    Found in app/Integrations/Magento/Synchronizer/Order.php and 1 other location - About 1 hr to fix
    app/Integrations/Magento/Synchronizer/Product.php on lines 69..79

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

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

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

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

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

    Refactorings

    Further Reading

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

        public function updateOrderInCrm(int $id, Maps\Inventory $mapModel): void

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

        ];

    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'])) {

    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'])) {

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

        }

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

         *

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

                                } else {

    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';

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

                                    $dataCrm['parent_id'] = $parentOrder;

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

                                    $dataCrm['magento_id'] = $order['entity_id'];

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

                        $this->config->setScan('order', 'id', $id);

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

            } else {

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

            }

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

        public function export(): bool

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

                    $this->updateOrderInMagento($row);

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

                }

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

        {

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

            $query = $queryGenerator->createQuery();

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

            $query->andWhere(['<=', 'modifiedtime', $this->lastScan['start_date']]);

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

         * @return void

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

                $this->config->setScan('order');

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

                $this->lastScan = $this->config->getLastScan('order');

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

            }

    Line exceeds 120 characters; contains 126 characters
    Open

                        $className = $this->config->get('order_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Order';

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

                        if ($dataCrm) {

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

                                    $mapModel->setDataCrm($dataCrm);

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

                                \App\Log::error('Error during saving order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

                \App\Log::error('Error during import order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

                foreach ($data['items'] as $item) {

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

         * Create order in crm.

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

            $searchCriteria[] = parent::getSearchCriteria($pageSize);

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

         *

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

         * @return \Generator

    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'])) {

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

                    foreach ($orders as $id => $order) {

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

                        }

    Line exceeds 120 characters; contains 123 characters
    Open

                \App\Log::error('Error during import order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

        public function createOrderInCrm(Maps\Inventory $mapModel)

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

        {

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

            }

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

        /**

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

         * Update order in magento.

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

        protected static $updateFields = [

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

                            continue;

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

                    $allChecked = true;

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

            } catch (\Throwable $ex) {

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

            return $allChecked;

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

            $items = [];

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

                    $items[$item['entity_id']] = $item;

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

         *

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

         */

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

         * @param int                                                   $id

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

            $recordModel = \Vtiger_Record_Model::getInstanceById($id, 'SSingleOrders');

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

        {

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

            $queryGenerator->setStateCondition('All');

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

            if ($updateData = $mapModel->getUpdateData()) {

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

            }

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

        /** {@inheritdoc} */

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

         * @return bool

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

                        $dataCrm = $mapModel->getDataCrm();

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

                $this->config->setScan('crm_order');

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

                                    }

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

        /**

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

            try {

    Line exceeds 120 characters; contains 181 characters
    Open

            $data = \App\Json::decode($this->connector->request('GET', $this->config->get('store_code') . '/V1/orders?' . $this->getSearchCriteria($this->config->get('orders_limit'))));

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

            if ($this->saveInventoryCrm($recordModel, $mapModel)) {

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

                            \App\Log::error('Empty order details', 'Integrations/Magento');

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

         *

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

                }

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

        {

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

         *

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

                    $this->config->setScan('crm_order', 'id', $row['id']);

    Line exceeds 120 characters; contains 161 characters
    Open

                \App\Log::error('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');

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

         * @param \App\Integrations\Magento\Synchronizer\Maps\Inventory $mapModel

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

                $allChecked = false;

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

         *

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

        }

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

        }

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

            $queryGenerator->addCondition('magento_server_id', $this->config->get('id'), 'e');

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

         * @param array $row

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

                $this->connector->request('POST', $this->config->get('store_code') . '/V1/orders/', $updateData);

    Line exceeds 120 characters; contains 130 characters
    Open

                throw new \Exception('No status mapping (in self::$statusForMagento): ' . $mapModel->dataCrm['ssingleorders_status']);

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

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

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

                throw new \Exception('No status mapping (in self::$statusForMagento): ' . $mapModel->dataCrm['ssingleorders_status']);

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

        }

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

                $this->lastScan = $this->config->getLastScan('crm_order');

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

                                if ($crmId = $mapModel->getCrmId($order['entity_id'])) {

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

                                        $dataCrm['contactid'] = $this->syncContact($customerDataCrm);

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

                    }

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

            return $items;

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

        }

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

        /**

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

         * @param \App\Integrations\Magento\Synchronizer\Maps\Inventory $mapModel

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

                    $recordModel->set($key, $value);

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

            $recordModel->save();

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

        }

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

         * Get changes for update.

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

            }

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

            $query->limit(10);

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

            }

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

            $this->lastScan = $this->config->getLastScan('crm_order');

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

            if ($this->export()) {

    Line exceeds 120 characters; contains 156 characters
    Open

                                        $customerClassName = $this->config->get('customer_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Customer';

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

                                        $customerMapModel->setData($customer);

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

                                }

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

                            \App\Log::error('Empty map order details', 'Integrations/Magento');

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

                }

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

            }

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

            foreach (self::$updateFields as $fieldname) {

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

            $searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][conditionType]=eq';

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

         * Export orders to magento.

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

            try {

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

            $queryGenerator->setFields(['id', 'magento_id', 'ssingleorders_status', 'subject'])->permissions = false;

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

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

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

        public function updateOrderInMagento(array $row): void

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

            $mapModel->setDataCrm($row);

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

            } else {

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

        {

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

         * Import orders from magento.

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

                                    } else {

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

                                    $dataCrm['accountid'] = $dataCrm['parent_id'];

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

                } else {

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

         *

    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/orders?' . $this->getSearchCriteria($this->config->get('orders_limit'))));

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

            return $recordModel->getId();

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

         *

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

        {

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

         */

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

            }

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

                yield $row;

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

         */

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

                \App\Log::error("No status mapping for: crmid: {$row['id']} | magento_id: {$row['magento_id']} | status: {$row['ssingleorders_status']}", 'Integrations/Magento');

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

            $this->lastScan = $this->config->getLastScan('order');

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

            }

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

            $allChecked = false;

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

                        $mapModel = new $className($this);

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

                        $mapModel->setData($order);

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

                                    if (empty($order['customer_id'])) {

    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']);

    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']);

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

        /**

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

         * @return array

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

            if (!empty($data['items'])) {

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

                }

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

                    $recordModel->set($fieldname, $mapModel->dataCrm[$fieldname]);

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

                }

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

        /** {@inheritdoc} */

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

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

        /**

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

         */

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

            if (!empty($this->lastScan['id'])) {

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

                $query->andWhere(['>=', 'modifiedtime', $this->lastScan['end_date']]);

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

            $mapModel = new $className($this);

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

        /** {@inheritdoc} */

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

            }

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

        public function import(): bool

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

                        $className = $this->config->get('order_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Order';

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

                                        $customerDataCrm = $customerMapModel->getDataCrm();

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

            if ($this->config->get('storage_id')) {

    Line exceeds 120 characters; contains 132 characters
    Open

                $this->log('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']');

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

            return implode('&', $searchCriteria);

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

            $allChecked = true;

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

         *

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

         *

    Line exceeds 120 characters; contains 174 characters
    Open

                \App\Log::error("No status mapping for: crmid: {$row['id']} | magento_id: {$row['magento_id']} | status: {$row['ssingleorders_status']}", 'Integrations/Magento');

    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'])) {

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

            }

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

                $this->config->setEndScan('crm_order', $this->lastScan['start_date']);

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

                if ($orders = $this->getOrdersFromApi()) {

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

                                    $crmId = $this->createOrderInCrm($mapModel);

    Line exceeds 120 characters; contains 139 characters
    Open

                                \App\Log::error('Error during saving order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

                            }

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

                $this->log('Import orders', $ex);

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

            }

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

            $recordModel->set('magento_server_id', $this->config->get('id'));

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

                $this->log('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']');

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

        }

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

         * @throws \Exception

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

         */

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

            $fields = $recordModel->getModule()->getFields();

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

                if (isset($mapModel->dataCrm[$fieldname], $fields[$fieldname])) {

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

        public function getSearchCriteria(int $pageSize = 10): string

    Line exceeds 120 characters; contains 123 characters
    Open

                \App\Log::error('Error during export order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

            return $allChecked;

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

        {

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

            if ($this->import()) {

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

                            try {

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

                                    $this->updateOrderInCrm($crmId, $mapModel);

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

                                        $dataCrm['contactid'] = $this->syncContact($dataCrm);

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

                                        $customerMapModel = new $customerClassName($this);

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

                                        $dataCrm['parent_id'] = $this->syncAccount($customerDataCrm);

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

                                $this->log('Saving order', $ex);

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

        }

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

                if (isset($fields[$key])) {

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

            $searchCriteria[] = 'searchCriteria[filter_groups][3][filters][0][field]=store_id';

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

                foreach ($this->getChanges() as $row) {

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

                    $allChecked = false;

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

        }

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

            $className = $this->config->get('order_map_class') ?: '\App\Integrations\Magento\Synchronizer\Maps\Order';

    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.

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

        {

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

                        if (empty($order)) {

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

                            } catch (\Throwable $ex) {

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

         * Method to get orders form Magento.

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

        public function getOrdersFromApi(): array

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

                $recordModel->set('istorageaddressid', $this->config->get('storage_id'));

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

            $fields = $recordModel->getModule()->getFields();

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

            foreach ($mapModel->dataCrm as $key => $value) {

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

                \App\Log::error('Skipped saving record, problem with inventory products | order id: [' . $mapModel->data['entity_id'] . ']', 'Integrations/Magento');

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

        /**

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

         * Method to update order in YetiForce.

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

        public function updateOrderInCrm(int $id, Maps\Inventory $mapModel): void

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

            }

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

            } catch (\Throwable $ex) {

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

                $this->log('Export orders', $ex);

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

        /**

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

                                        $dataCrm['parent_id'] = $this->syncAccount($dataCrm);

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

            }

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

         */

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

            }

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

                $query->andWhere(['>', 'ssingleordersid', $this->lastScan['id']]);

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

            if (!empty($this->lastScan['end_date'])) {

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

            'ssingleorders_status', 'status_magento',

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

        public function process()

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

                $this->config->setEndScan('order', $this->lastScan['start_date']);

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

            $this->config->setScan('crm_order');

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

         */

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

                        }

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

                                    $parentOrder = $dataCrm['parent_id'];

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

                                        $customer = $this->getFromApi('customers', $order['customer_id']);

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

                                    \App\Cache::staticSave('CrmIdByMagentoIdSSingleOrders', $order['entity_id'], $crmId);

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

                        } else {

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

        {

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

         * @return mixed|int

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

            $recordModel = \Vtiger_Record_Model::getCleanInstance('SSingleOrders');

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

                $recordModel->save();

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

         * @return bool

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

                \App\Log::error('Error during export order: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'Integrations/Magento');

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

        public function getChanges(): \Generator

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

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

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

            $query->andWhere(new \yii\db\Expression('modifiedtime <> createdtime'));

    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']);

    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']);

    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']);

    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']);

    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']);

    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']);

    There are no issues that match your filters.

    Category
    Status