YetiForceCompany/YetiForceCRM

View on GitHub
app/Integrations/Wapro/Synchronizer/Products.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

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

    public function process(): int
    {
        $query = (new \App\Db\Query())->select([
            'dbo.ARTYKUL.*',
            'category' => 'dbo.KATEGORIA_ARTYKULU_TREE.NAZWA',
Severity: Minor
Found in app/Integrations/Wapro/Synchronizer/Products.php - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Method process has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(): int
    {
        $query = (new \App\Db\Query())->select([
            'dbo.ARTYKUL.*',
            'category' => 'dbo.KATEGORIA_ARTYKULU_TREE.NAZWA',
Severity: Major
Found in app/Integrations/Wapro/Synchronizer/Products.php - About 2 hrs to fix

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

        public function process(): int
        {
            $query = (new \App\Db\Query())->select([
                'dbo.ARTYKUL.*',
                'category' => 'dbo.KATEGORIA_ARTYKULU_TREE.NAZWA',

    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

    Missing class import via use statement (line '51', column '17').
    Open

            $query = (new \App\Db\Query())->select([

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

            return $this->cache[$id] = (new \App\Db\Query())->select([

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

            return (new \App\Db\Query())->from('dbo.ARTYKUL')->count('*', $this->controller->getDb());

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Avoid using static access to class '\App\Cache' in method 'importRecord'.
    Open

            \App\Cache::save('WaproMapTable', "{$this->waproId}|ARTYKUL", $this->recordModel->getId());

    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\Json' in method 'convertPrice'.
    Open

            return \App\Json::encode([
                'currencies' => [
                    $currency['currencyId'] => ['price' => $value]
                ],
                'currencyId' => $currency['currencyId']

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

        public function process(): int
        {
            $query = (new \App\Db\Query())->select([
                'dbo.ARTYKUL.*',
                'category' => 'dbo.KATEGORIA_ARTYKULU_TREE.NAZWA',

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

                $this->recordModel = \Vtiger_Record_Model::getInstanceById($id, 'Products');

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

        public function importRecord(): int
        {
            if ($id = $this->findInMapTable($this->waproId, 'ARTYKUL')) {
                $this->recordModel = \Vtiger_Record_Model::getInstanceById($id, 'Products');
            } else {

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

                $this->recordModel = \Vtiger_Record_Model::getCleanInstance('Products');

    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\Pauser' in method 'process'.
    Open

            $pauser = \App\Pauser::getInstance('WaproProductsLastId');

    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 importRecord uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $this->recordModel = \Vtiger_Record_Model::getCleanInstance('Products');
                $this->recordModel->setDataForSave([\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME => [
                    'wtable' => 'ARTYKUL',
                ]]);

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    Avoid using static access to class '\App\Fields\Tree' in method 'convertCategory'.
    Open

            $list = \App\Fields\Tree::getPicklistValue($fieldModel->getFieldParams(), $fieldModel->getModuleName());

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

            'unitName' => ['fieldName' => 'usageunit', 'fn' => 'convertUnitName', 'moduleName' => 'Products'],

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

            'NAZWA' => ['fieldName' => 'productname', 'fn' => 'decode'],

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

                    $currency['currencyId'] => ['price' => $value]

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

            'unitName' => ['fieldName' => 'usageunit', 'fn' => 'convertUnitName', 'moduleName' => 'Products'],

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

            ])->from('dbo.ARTYKUL')

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

            'total' => ['fieldName' => 'unit_price', 'fn' => 'convertPrice'],

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

            'NAZWA' => ['fieldName' => 'productname', 'fn' => 'decode'],

    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.

    Move this "case default" clause to the end of this "switch" statement.
    Open

                            default:

    The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

    Noncompliant Code Example

    switch ($param) {  //missing default clause
      case 0:
        do_something();
        break;
      case 1:
        do_something_else();
        break;
    }
    
    switch ($param) {
      default: // default clause should be the last one
        error();
        break;
      case 0:
        do_something();
        break;
      case 1:
        do_something_else();
        break;
    }
    

    Compliant Solution

    switch ($param) {
      case 0:
        do_something();
        break;
      case 1:
        do_something_else();
        break;
      default:
        error();
        break;
    }
    

    See

    • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
    • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
    • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
    • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
    • MISRA C:2012, 16.1 - All switch statements shall be well-formed
    • MISRA C:2012, 16.4 - Every switch statement shall have a default label
    • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
    • MITRE, CWE-478 - Missing Default Case in Switch Statement
    • CERT, MSC01-C. - Strive for logical completeness
    • CERT, MSC01-CPP. - Strive for logical completeness

    Define a constant instead of duplicating this literal "category" 3 times.
    Open

            'category' => ['fieldName' => 'pscategory', 'fn' => 'convertCategory'],

    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 '$params'.
    Open

        protected function convertTaxes(string $value, array $params): string

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid unused parameters such as '$params'.
    Open

        protected function convertPrice(string $value, array $params): string

    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 undeclared method \App\Db\Query::select
    Open

            $query = (new \App\Db\Query())->select([

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

            return $this->cache[$id] = (new \App\Db\Query())->select([

    Argument 1 (templateId) is array but \App\Fields\Tree::getPicklistValue() takes int defined at /code/app/Fields/Tree.php:61
    Open

            $list = \App\Fields\Tree::getPicklistValue($fieldModel->getFieldParams(), $fieldModel->getModuleName());

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

            return (new \App\Db\Query())->from('dbo.ARTYKUL')->count('*', $this->controller->getDb());

    Argument 1 (value) is int but \App\Pauser::setValue() takes string defined at /code/app/Pauser.php:77
    Open

                $pauser->setValue($lastId);

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

            $lastId = $s = $e = $i = $u = 0;

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

        public function getRecordById(int $id): array

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

            $lastId = $s = $e = $i = $u = 0;

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

            $lastId = $s = $e = $i = $u = 0;

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

        public function importRecordById(int $id): int

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

            $lastId = $s = $e = $i = $u = 0;

    ShortVariable

    Since: 0.2

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

    Example

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

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

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

            if ($id = $this->findInMapTable($this->waproId, 'ARTYKUL')) {

    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

        /** {@inheritdoc} */

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

                'dbo.ARTYKUL.*',

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

                'unitName' => 'dbo.JEDNOSTKA.SKROT',

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

            'VAT_SPRZEDAZY' => ['fieldName' => 'taxes', 'fn' => 'convertTaxes'],

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

                'category' => 'dbo.KATEGORIA_ARTYKULU_TREE.NAZWA',

    Line exceeds 120 characters; contains 134 characters
    Open

                ->leftJoin('dbo.KATEGORIA_ARTYKULU_TREE', 'dbo.ARTYKUL.ID_KATEGORII_TREE = dbo.KATEGORIA_ARTYKULU_TREE.ID_KATEGORII_TREE')

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

                'total' => 'dbo.CENA_ARTYKULU.CENA_NETTO',

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

                ->leftJoin('dbo.JEDNOSTKA', 'dbo.ARTYKUL.ID_JEDNOSTKI = dbo.JEDNOSTKA.ID_JEDNOSTKI')

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

        protected $fieldMap = [

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

            'total' => ['fieldName' => 'unit_price', 'fn' => 'convertPrice'],

    Line exceeds 120 characters; contains 159 characters
    Open

                ->leftJoin('dbo.CENA_ARTYKULU', 'dbo.ARTYKUL.ID_ARTYKULU = dbo.CENA_ARTYKULU.ID_ARTYKULU AND dbo.ARTYKUL.ID_CENY_DOM = dbo.CENA_ARTYKULU.ID_CENY');

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

        const SEQUENCE = 4;

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

            'STAN_MINIMALNY' => 'reorderlevel',

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

            'WAGA' => 'weight',

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

                ->leftJoin('dbo.CENA_ARTYKULU', 'dbo.ARTYKUL.ID_ARTYKULU = dbo.CENA_ARTYKULU.ID_ARTYKULU AND dbo.ARTYKUL.ID_CENY_DOM = dbo.CENA_ARTYKULU.ID_CENY');

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

                ->leftJoin('dbo.KATEGORIA_ARTYKULU_TREE', 'dbo.ARTYKUL.ID_KATEGORII_TREE = dbo.KATEGORIA_ARTYKULU_TREE.ID_KATEGORII_TREE')

    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

            'INDEKS_HANDLOWY' => ['fieldName' => 'serial_no', 'fn' => 'decode'],

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

        public function process(): int

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

        const NAME = 'LBL_PRODUCTS';

    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

            'KOD_KRESKOWY' => 'ean',

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

            'category' => ['fieldName' => 'pscategory', 'fn' => 'convertCategory'],

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

            'INDEKS_KATALOGOWY' => ['fieldName' => 'mfr_part_no', 'fn' => 'decode'],

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

        {

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

            'OPIS' => 'description',

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

            'CENA_ZAKUPU_BRUTTO' => ['fieldName' => 'purchase', 'fn' => 'convertPrice'],

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

                'gross' => 'dbo.CENA_ARTYKULU.CENA_BRUTTO',

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

            'NAZWA' => ['fieldName' => 'productname', 'fn' => 'decode'],

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

            'STAN' => 'qtyinstock',

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

            $query = (new \App\Db\Query())->select([

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

                    'wtable' => 'ARTYKUL',

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

            $this->recordModel->set('wapro_id', $this->waproId);

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

                    $currency['currencyId'] => ['price' => $value]

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

            } catch (\Throwable $th) {

    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

            'unitName' => ['fieldName' => 'usageunit', 'fn' => 'convertUnitName', 'moduleName' => 'Products'],

    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 ($this->skip) {

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

            \App\Cache::save('WaproMapTable', "{$this->waproId}|ARTYKUL", $this->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

            return \App\Json::encode([

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

        protected function convertCategory(string $value, array $params): string

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

         *

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

        {

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

        }

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

        /**

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

                $this->importRecord();

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

         *

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

        /** @var array Cache form products */

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

        protected $cache = [];

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

                $pauser->setValue($lastId);

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

            return $i + $u;

    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 int

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

            return $this->recordModel->getId();

    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

            'STAN_MAKSYMALNY' => 'qtyindemand',

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

            'INDEKS_PRODUCENTA' => 'vendor_part_no',

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

        ];

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

            ])->from('dbo.ARTYKUL')

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

                    $this->row = $row;

    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

            }

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

            $this->recordModel->save();

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

            if ($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

            $fieldModel = $this->recordModel->getField($params['fieldName']);

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

            $key = array_search($value, $list);

    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

            ])->from('dbo.ARTYKUL')

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

                    $this->waproId = $row['ID_ARTYKULU'];

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

                        switch ($this->importRecord()) {

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

                    } catch (\Throwable $th) {

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

                        $this->logError($th);

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

                    break;

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

            } else {

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

                return 0;

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

         * @param array  $params

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

         * @return string

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

        /**

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

         * Convert taxes to system format.

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

         * @param array  $params

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

         * @return string

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

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

            if (isset($this->cache[$id])) {

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

                'unitName' => 'dbo.JEDNOSTKA.SKROT',

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

            foreach ($query->batch(100, $this->controller->getDb()) as $rows) {

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

                                ++$u;

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

                                break;

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

                                ++$i;

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

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

            return $key ?? '';

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

        /**

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

            }

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

                'total' => 'dbo.CENA_ARTYKULU.CENA_NETTO',

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

            $lastId = $s = $e = $i = $u = 0;

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

                            case 0:

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

                if ($this->controller->cron && $this->controller->cron->checkTimeout()) {

    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->recordModel = \Vtiger_Record_Model::getCleanInstance('Products');

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

            $this->recordModel->set('discontinued', 1);

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

                ],

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

         * Convert category to system format.

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

         */

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

            $pauser = \App\Pauser::getInstance('WaproProductsLastId');

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

                $query->where(['>', 'dbo.ARTYKUL.ID_ARTYKULU', $val]);

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

                    $this->skip = false;

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

                            default:

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

                            case 2:

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

                        ++$e;

    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

        public function importRecord(): int

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

        }

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

         * Convert price to system format.

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

            }

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

         *

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

                                break;

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

        }

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

        {

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

        }

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

        protected function convertTaxes(string $value, array $params): string

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

         *

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

         */

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

         */

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

                throw $th;

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

         * @param string $value

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

        public function importRecordById(int $id): int

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

            $this->row = $this->getRecordById($id);

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

                ->leftJoin('dbo.KATEGORIA_ARTYKULU_TREE', 'dbo.ARTYKUL.ID_KATEGORII_TREE = dbo.KATEGORIA_ARTYKULU_TREE.ID_KATEGORII_TREE')

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

            if ($val = $pauser->getValue()) {

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

                $this->recordModel = \Vtiger_Record_Model::getInstanceById($id, 'Products');

    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->log("Create {$i} | Update {$u} | Skipped {$s} | Error {$e}");

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

                $this->recordModel->setDataForSave([\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME => [

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

        /**

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

            $currency = $this->getBaseCurrency();

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

         *

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

                'dbo.ARTYKUL.*',

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

                'category' => 'dbo.KATEGORIA_ARTYKULU_TREE.NAZWA',

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

                'gross' => 'dbo.CENA_ARTYKULU.CENA_BRUTTO',

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

                ->where(['dbo.ARTYKUL.ID_ARTYKULU' => $id])

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

                                break;

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

            $this->loadFromFieldMap();

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

            }

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

         * @param string $value

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

            return $this->getGlobalTax($value, 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

            $this->waproId = $this->row['ID_ARTYKULU'];

    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

                ->leftJoin('dbo.CENA_ARTYKULU', 'dbo.ARTYKUL.ID_CENY_DOM = dbo.CENA_ARTYKULU.ID_CENY')

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

                ->one($this->controller->getDb()) ?? [];

    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

        /** {@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

        protected function convertPrice(string $value, array $params): string

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

                $this->logError($th);

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

                $lastId = 0;

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

                    $this->cache[$this->waproId] = $row;

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

            $list = \App\Fields\Tree::getPicklistValue($fieldModel->getFieldParams(), $fieldModel->getModuleName());

    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

        public function getRecordById(int $id): array

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

                return $this->cache[$id];

    Line exceeds 120 characters; contains 134 characters
    Open

                ->leftJoin('dbo.KATEGORIA_ARTYKULU_TREE', 'dbo.ARTYKUL.ID_KATEGORII_TREE = dbo.KATEGORIA_ARTYKULU_TREE.ID_KATEGORII_TREE')

    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 ($rows as $row) {

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

                $pauser->destroy();

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

                return $this->recordModel->getPreviousValue() ? 1 : 3;

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

         * @param string $value

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

         * @return string

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

                'currencies' => [

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

                'currencyId' => $currency['currencyId']

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

            ]);

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

         * @param array  $params

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

         * Get product record by record id.

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

                                ++$s;

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

                            case 1:

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

                        $lastId = $this->waproId;

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

            if (0 == $lastId) {

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

            if ($id = $this->findInMapTable($this->waproId, 'ARTYKUL')) {

    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 record by 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

            return $this->cache[$id] = (new \App\Db\Query())->select([

    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

        {

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

            return (new \App\Db\Query())->from('dbo.ARTYKUL')->count('*', $this->controller->getDb());

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

                ->leftJoin('dbo.JEDNOSTKA', 'dbo.ARTYKUL.ID_JEDNOSTKI = dbo.JEDNOSTKA.ID_JEDNOSTKI')

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

        public function getCounter(): int

    There are no issues that match your filters.

    Category
    Status