YetiForceCompany/YetiForceCRM

View on GitHub
modules/Import/readers/CSVReader.php

Summary

Maintainability
D
2 days
Test Coverage
F
0%

Function read has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    public function read()
    {
        $this->createTable();
        $fieldMapping = $this->request->get('field_mapping');
        $inventoryFieldMapping = $this->request->get('inventory_field_mapping');
Severity: Minor
Found in modules/Import/readers/CSVReader.php - About 7 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

Function getFirstRowData has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFirstRowData($hasHeader = true)
    {
        $isInventory = $this->moduleModel->isInventory();
        $rowData = $headers = $standardData = $inventoryData = [];
        foreach ($this->data as $currentRow => $data) {
Severity: Minor
Found in modules/Import/readers/CSVReader.php - About 5 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 read has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function read()
    {
        $this->createTable();
        $fieldMapping = $this->request->get('field_mapping');
        $inventoryFieldMapping = $this->request->get('inventory_field_mapping');
Severity: Major
Found in modules/Import/readers/CSVReader.php - About 2 hrs to fix

    Method getFirstRowData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFirstRowData($hasHeader = true)
        {
            $isInventory = $this->moduleModel->isInventory();
            $rowData = $headers = $standardData = $inventoryData = [];
            foreach ($this->data as $currentRow => $data) {
    Severity: Minor
    Found in modules/Import/readers/CSVReader.php - About 1 hr to fix

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

          public function arrayCombine($keys, $values)
          {
              $combine = $dup = [];
              foreach ($keys as $key => $keyData) {
                  if (isset($combine[$keyData])) {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.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 read() has an NPath complexity of 26042. The configured NPath complexity threshold is 200.
      Open

          public function read()
          {
              $this->createTable();
              $fieldMapping = $this->request->get('field_mapping');
              $inventoryFieldMapping = $this->request->get('inventory_field_mapping');
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

          public function getFirstRowData($hasHeader = true)
          {
              $isInventory = $this->moduleModel->isInventory();
              $rowData = $headers = $standardData = $inventoryData = [];
              foreach ($this->data as $currentRow => $data) {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

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

          public function read()
          {
              $this->createTable();
              $fieldMapping = $this->request->get('field_mapping');
              $inventoryFieldMapping = $this->request->get('inventory_field_mapping');
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

          public function read()
      Severity: Critical
      Found in modules/Import/readers/CSVReader.php by sonar-php

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Refactor this function to reduce its Cognitive Complexity from 36 to the 15 allowed.
      Open

          public function getFirstRowData($hasHeader = true)
      Severity: Critical
      Found in modules/Import/readers/CSVReader.php by sonar-php

      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 '$inventoryHeaders' which will lead to PHP notices.
      Open

                      $rowData['LBL_INVENTORY_FIELDS'] = $this->arrayCombine($inventoryHeaders, $inventoryData);
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 '$inventoryHeaders' which will lead to PHP notices.
      Open

                                  $inventoryHeaders[$key] = \App\Purifier::purify($value);
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 '$inventoryHeaders' which will lead to PHP notices.
      Open

                              if (!empty($isInventory) && isset($inventoryHeaders[$key])) {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 '$inventoryNames' which will lead to PHP notices.
      Open

                              $key = array_search($columnParamsName, $inventoryNames);
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 '$inventoryNames' which will lead to PHP notices.
      Open

                          if (\in_array($columnParamsName, $inventoryNames)) {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 '$inventoryNames' which will lead to PHP notices.
      Open

                                  $inventoryNames[$index] = $name;
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

              $csv = new \ParseCsv\Csv();
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      MissingImport

      Since: 2.7.0

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

      Example

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

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

      The method getFirstRowData has a boolean flag argument $hasHeader, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function getFirstRowData($hasHeader = true)
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      Avoid using static access to class '\App\Config' in method '__construct'.
      Open

              $csv->encoding($this->request->get('file_encoding'), \App\Config::main('default_charset', 'UTF-8'));
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Purifier' in method 'getFirstRowData'.
      Open

                                  $inventoryHeaders[$key] = \App\Purifier::purify($value);
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

                              } else {
                                  $standardData[$key] = $value;
                              }
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

                      } else {
                          foreach ($data as $key => $value) {
                              if (!empty($isInventory) && isset($inventoryHeaders[$key])) {
                                  $inventoryData[$key] = $value;
                              } else {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

              } else {
                  $rowData = $standardData;
              }
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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\Purifier' in method 'getFirstRowData'.
      Open

                                  $headers[$key] = \App\Purifier::purify($value);
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

                              } else {
                                  $headers[$key] = \App\Purifier::purify($value);
                              }
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 'Vtiger_Inventory_Model' in method 'read'.
      Open

                  $inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleModel->getName());
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

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

                              } else {
                                  $skip = $index;
                              }
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      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 unused local variables such as '$dataType'.
      Open

                      foreach ($fieldModel->getCustomColumn() as $columnParamsName => $dataType) {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

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

      Variable $inventoryNames is undeclared
      Open

                          if (\in_array($columnParamsName, $inventoryNames)) {
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Variable $inventoryNames is undeclared
      Open

                              $key = array_search($columnParamsName, $inventoryNames);
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Parameter $user has undeclared type \App\User (Did you mean class \Tests\App\User)
      Open

          public function __construct(App\Request $request, App\User $user)
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Reference to instance property heading from undeclared class \ParseCsv\Csv
      Open

              $csv->heading = false;
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Reference to instance property use_mb_convert_encoding from undeclared class \ParseCsv\Csv
      Open

              $csv->use_mb_convert_encoding = true;
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Reference to instance property data from undeclared class \ParseCsv\Csv
      Open

              $this->data = $csv->data;
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Call to method encoding from undeclared class \ParseCsv\Csv
      Open

              $csv->encoding($this->request->get('file_encoding'), \App\Config::main('default_charset', 'UTF-8'));
      Severity: Critical
      Found in modules/Import/readers/CSVReader.php by phan

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

                                  $inventoryNames[$index] = $name;
      Severity: Info
      Found in modules/Import/readers/CSVReader.php by phan

      Reference to instance property delimiter from undeclared class \ParseCsv\Csv
      Open

              $csv->delimiter = $this->request->get('delimiter');
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phan

      Call to method parseFile from undeclared class \ParseCsv\Csv
      Open

              $csv->parseFile($this->getFilePath());
      Severity: Critical
      Found in modules/Import/readers/CSVReader.php by phan

      Call to method __construct from undeclared class \ParseCsv\Csv
      Open

              $csv = new \ParseCsv\Csv();
      Severity: Critical
      Found in modules/Import/readers/CSVReader.php by phan

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

                                  $inventoryHeaders[$key] = \App\Purifier::purify($value);
      Severity: Info
      Found in modules/Import/readers/CSVReader.php by phan

      Avoid excessively long variable names like $inventoryFieldMapping. Keep variable name length under 20.
      Open

              $inventoryFieldMapping = $this->request->get('inventory_field_mapping');
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

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

      Each class must be in a namespace of at least one level (a top-level vendor name)
      Open

      class Import_CSVReader_Reader extends Import_FileReader_Reader

      The class Import_CSVReader_Reader is not named in CamelCase.
      Open

      class Import_CSVReader_Reader extends Import_FileReader_Reader
      {
          /**
           * Parsed file data.
           *
      Severity: Minor
      Found in modules/Import/readers/CSVReader.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

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

              $csv = new \ParseCsv\Csv();

      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

          private $data;

      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

              $csv->encoding($this->request->get('file_encoding'), \App\Config::main('default_charset', 'UTF-8'));

      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

           * Creates a table using one table's values as keys, and the other's as values.

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

           *

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

                      $keyData = $keyData . '(' . ++$dup[$keyData] . ')';

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

           * @var array

      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

          public function arrayCombine($keys, $values)

      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 array $keys

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

                  if (isset($combine[$keyData])) {

      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\Request $request

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

              $csv->delimiter = $this->request->get('delimiter');

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

              foreach ($keys as $key => $keyData) {

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

           *

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

              $csv->heading = false;

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

           * @param \App\User    $user

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

                          foreach ($data as $key => $value) {

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

                                  $inventoryData[$key] = $value;

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

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

                  $values = array_merge($values, array_fill($noOfFirstRowData, $noOfHeaders - $noOfFirstRowData, ''));

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

              } elseif ($noOfHeaders < $noOfFirstRowData) {

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

              $inventoryFieldMapping = $this->request->get('inventory_field_mapping');

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

                  $inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleModel->getName());

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

                  $allValuesEmpty = true;

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

                      $fieldValue = $data[$index];

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

           * Import_CSVReader_Reader constructor.

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

          public function __construct(App\Request $request, App\User $user)

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

              $csv->parseFile($this->getFilePath());

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

              $this->data = $csv->data;

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

           * @param array $values

      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

                              } 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

                      $inventoryMappedData[$i][$fieldName] = $fieldValue;

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

              $csv->use_mb_convert_encoding = true;

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

                      if (!isset($dup[$keyData])) {

      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 bool $hasHeader

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

           */

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

              $isInventory = $this->moduleModel->isInventory();

      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

              if ($noOfHeaders > $noOfFirstRowData) {

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

              $sourceId = $this->request->getInteger('src_record');

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

                                  $skip = $index;

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

                  $mappedData = $inventoryMappedData = [];

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

                          if (\in_array($columnParamsName, $inventoryNames)) {

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

                              if (!empty($isInventory) && isset($inventoryHeaders[$key])) {

      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

              $fieldMapping = $this->request->get('field_mapping');

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

                          }

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

                      $mappedData[$fieldName] = $fieldValue;

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

              return $combine;

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

          public function getFirstRowData($hasHeader = true)

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

              $rowData = $headers = $standardData = $inventoryData = [];

      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

              foreach ($this->data as $i => $data) {

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

                      $fieldValueTemp = $fieldValue;

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

                      if (!empty($fieldValue)) {

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

                      }

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

           * Parsed file data.

      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

                      foreach ($fieldModel->getCustomColumn() as $columnParamsName => $dataType) {

      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

           * Function gets data of the first record to import.

      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 ($this->data as $currentRow => $data) {

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

                          foreach ($data as $key => $value) {

      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

                          $allValuesEmpty = 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

              parent::__construct($request, $user);

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

              $combine = $dup = [];

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

                          $dup[$keyData] = 1;

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

                              if (!empty($isInventory) && 0 === strpos($value, 'Inventory::')) {

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

                                  $standardData[$key] = $value;

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

          {

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

              $noOfFirstRowData = \count($values);

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

              $skip = $importId = $skipData = false;

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

                      foreach ($data as $index => $fullName) {

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

                      }

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

                      $mappedData['relation_id'] = $relationId;

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

                  }

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

                      $fieldValueTemp = str_replace(',', '.', $fieldValueTemp);

      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

                  $rowData = $standardData;

      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

           * Function creates tables for import in database.

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

          public function read()

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

                  if ($sourceId && $relationId) {

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

                  }

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

              $relationId = $this->request->getInteger('relationId');

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

                              $name = substr($fullName, 11);

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

                                  $inventoryNames[$index] = $name;

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

                  foreach ($inventoryFieldMapping as $fieldName => $index) {

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

                      $fieldValue = $data[$index];

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

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

              if ($this->moduleModel->isInventory()) {

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

                          if ($this->moduleModel->isInventory() && 0 === strpos($fullName, 'Inventory::')) {

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

                          $importId = $this->addRecordToDB($mappedData);

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

                                  $headers[$key] = \App\Purifier::purify($value);

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

           * @param array $keys

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

           * @param array $values

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

                      $fieldModel = $inventoryFields[$fieldName];

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

                  $combine[$keyData] = $values[$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

                                  $value = substr($value, 11);

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

                              }

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

                  $standardData = $this->syncRowData($headers, $standardData);

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

                  if ($inventoryData) {

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

              return $rowData;

      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 syncRowData($keys, $values)

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

                              if ('recordIteration' !== $name) {

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

                      $mappedData['src_record'] = $sourceId;

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

                              $key = array_search($columnParamsName, $inventoryNames);

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

                      if (!$skip || !$importId || ($skip && $skipData !== $data[$skip])) {

      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 (0 === $currentRow || (1 === $currentRow && $hasHeader)) {

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

                      if ($hasHeader && 0 === $currentRow) {

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

           * Adjust first row data to get in sync with the number of headers.

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

                  $inventoryFields = $inventoryModel->getFields();

      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

                          $this->addInventoryToDB($inventoryMappedData, $importId);

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

                      if ($skip) {

      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

                  $rowData['LBL_STANDARD_FIELDS'] = $this->arrayCombine($headers, $standardData);

      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

                  foreach ($fieldMapping as $fieldName => $index) {

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

                          $fieldValue = $fieldValueTemp;

      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 ($importId && $inventoryMappedData) {

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

          }

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

                                  $inventoryHeaders[$key] = \App\Purifier::purify($value);

      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

                      $rowData['LBL_INVENTORY_FIELDS'] = $this->arrayCombine($inventoryHeaders, $inventoryData);

      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

              $noOfHeaders = \count($keys);

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

                  $values = \array_slice($values, 0, \count($keys), true);

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

              return $values;

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

                  if ($this->request->get('has_header') && 0 === $i) {

      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

                      if (is_numeric($fieldValueTemp)) {

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

                              $inventoryMappedData[$i][$columnParamsName] = $data[$key];

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

                  if (!$allValuesEmpty) {

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

                          $skipData = $data[$skip];

      Class name "Import_CSVReader_Reader" is not in camel caps format
      Open

      class Import_CSVReader_Reader extends Import_FileReader_Reader

      There are no issues that match your filters.

      Category
      Status