YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

Function createTable has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function createTable()
    {
        $db = \App\Db::getInstance();
        $schema = $db->getSchema();
        $tableName = Import_Module_Model::getDbTableName($this->user);
Severity: Minor
Found in modules/Import/readers/FileReader.php - About 3 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 createTable has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createTable()
    {
        $db = \App\Db::getInstance();
        $schema = $db->getSchema();
        $tableName = Import_Module_Model::getDbTableName($this->user);
Severity: Minor
Found in modules/Import/readers/FileReader.php - About 2 hrs to fix

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

        public function createTable()
        {
            $db = \App\Db::getInstance();
            $schema = $db->getSchema();
            $tableName = Import_Module_Model::getDbTableName($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 23 to the 15 allowed.
    Open

        public function createTable()
    Severity: Critical
    Found in modules/Import/readers/FileReader.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

    Remove error control operator '@' on line 107.
    Open

        public function deleteFile()
        {
            $filePath = $this->getFilePath();
            @unlink($filePath);
        }
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

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

    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/FileReader.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 'Vtiger_Module_Model' in method '__construct'.
    Open

            $this->moduleModel = Vtiger_Module_Model::getInstance($this->request->get('module'));
    Severity: Minor
    Found in modules/Import/readers/FileReader.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\Db' in method 'addInventoryToDB'.
    Open

            $db = \App\Db::getInstance();
    Severity: Minor
    Found in modules/Import/readers/FileReader.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\Utils' in method 'convertCharacterEncoding'.
    Open

            return \App\Utils::convertCharacterEncoding($value, $fromCharset, $toCharset);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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\Db' in method 'createTable'.
    Open

            $db = \App\Db::getInstance();
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 'Import_Module_Model' in method 'addInventoryToDB'.
    Open

            $tableName = Import_Module_Model::getInventoryDbTableName($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 'Import_Module_Model' in method 'addRecordToDB'.
    Open

            $tableName = Import_Module_Model::getDbTableName($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 assigning values to variables in if clauses and the like (line '130', column '8').
    Open

        public function createTable()
        {
            $db = \App\Db::getInstance();
            $schema = $db->getSchema();
            $tableName = Import_Module_Model::getDbTableName($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phpmd

    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 'Import_Module_Model' in method 'createTable'.
    Open

                $inventoryTableName = Import_Module_Model::getInventoryDbTableName($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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\Db' in method 'addRecordToDB'.
    Open

            $db = \App\Db::getInstance();
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 'Import_Module_Model' in method 'createTable'.
    Open

            $tableName = Import_Module_Model::getDbTableName($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 'Vtiger_Inventory_Model' in method 'createTable'.
    Open

                $inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleModel->getName());
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 'Import_Utils_Helper' in method 'getFilePath'.
    Open

            return Import_Utils_Helper::getImportFilePath($this->user);
    Severity: Minor
    Found in modules/Import/readers/FileReader.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 createTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                    } else {
                        $columns[$fieldName] = $field->getDBColumnType();
                    }
    Severity: Minor
    Found in modules/Import/readers/FileReader.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

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

            if ('on' == $this->request->get('has_header') || 1 == $this->request->get('has_header') || true === $this->request->get('has_header')) {
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by sonar-php

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

                'recordid' => 'integer',
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

    Remove the unused function parameter "$hasHeader".
    Open

        public function getFirstRowData($hasHeader = true)

    Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

    Noncompliant Code Example

    function doSomething($a, $b) { // "$a" is unused
      return compute($b);
    }
    

    Compliant Solution

    function doSomething($b) {
      return compute($b);
    }
    

    Exceptions

    Functions in classes that override a class or implement interfaces are ignored.

    class C extends B {
    
      function doSomething($a, $b) {     // no issue reported on $b
        compute($a);
      }
    
    }
    

    See

    • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
    • MISRA C:2012, 2.7 - There should be no unused parameters in functions
    • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
    • CERT, MSC12-CPP. - Detect and remove code that has no effect

    Avoid unused local variables such as '$index'.
    Open

            foreach ($fieldMapping as $fieldName => $index) {
    Severity: Minor
    Found in modules/Import/readers/FileReader.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

    Avoid unused parameters such as '$hasHeader'.
    Open

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

    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::createCommand
    Open

                $db->createCommand()->insert($tableName, $data)->execute();
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by phan

    Reference to constant TYPE_SMALLINT from undeclared class \yii\db\Schema (Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema)
    Open

                $columns['relation_id'] = $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 5)->defaultValue(0);
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by phan

    Call to undeclared method \App\Db::createCommand
    Open

            $db->createCommand()->insert($tableName, $data)->execute();
    Severity: Critical
    Found in modules/Import/readers/FileReader.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/FileReader.php by phan

    Call to undeclared method \App\Db::createCommand
    Open

                $db->createCommand()->createIndex('id_idx', $inventoryTableName, 'id')->execute();
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by phan

    Returning type string but addRecordToDB() is declared to return int
    Open

            return $db->getLastInsertID($tableName . '_id_seq');
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phan

    Call to undeclared method \App\Db::createCommand
    Open

                $db->createCommand()->addForeignKey('fk_1_' . $inventoryTableName, $inventoryTableName, 'id', $tableName, 'id', 'CASCADE', 'RESTRICT')->execute();
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by phan

    Argument 1 (moduleName) is false but \Vtiger_Inventory_Model::getInstance() takes string defined at /code/modules/Vtiger/models/Inventory.php:50
    Open

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

    Reference to constant TYPE_SMALLINT from undeclared class \yii\db\Schema (Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema)
    Open

                'temp_status' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 1)->defaultValue(0),
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by phan

    Call to undeclared method \App\Db::getSchema
    Open

            $schema = $db->getSchema();
    Severity: Critical
    Found in modules/Import/readers/FileReader.php by phan

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

    class Import_FileReader_Reader

    The property $temp_status is not named in camelCase.
    Open

    class Import_FileReader_Reader
    {
        public $temp_status = 'success';
        public $numberOfRecordsRead = 0;
        public $errorMessage = '';
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phpmd

    CamelCasePropertyName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name attributes.

    Example

    class ClassName {
        protected $property_name;
    }

    Source

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

            $db = \App\Db::getInstance();
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phpmd

    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 $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phpmd

    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

    The class Import_FileReader_Reader is not named in CamelCase.
    Open

    class Import_FileReader_Reader
    {
        public $temp_status = 'success';
        public $numberOfRecordsRead = 0;
        public $errorMessage = '';
    Severity: Minor
    Found in modules/Import/readers/FileReader.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

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

            $db = \App\Db::getInstance();
    Severity: Minor
    Found in modules/Import/readers/FileReader.php by phpmd

    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

        public $temp_status = 'success';

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

        public $moduleModel;

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

        public $user;

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

         * Constructor.

    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 getErrorMessage()

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

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

         * Function adds imported data to database.

    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\User    $user

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

            return Import_Utils_Helper::getImportFilePath($this->user);

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

            if (!file_exists($filePath)) {

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

                $this->errorMessage = 'ERR_FILE_DOESNT_EXIST';

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

        public function deleteFile()

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

            $moduleFields = $this->moduleModel->getFields();

    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 $errorMessage = '';

    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 ('on' == $this->request->get('has_header') || 1 == $this->request->get('has_header') || true === $this->request->get('has_header')) {

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

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

                $this->temp_status = 'failed';

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

            $fileHandler = fopen($filePath, 'r');

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

         * @param mixed $toCharset

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

         */

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

            $schema = $db->getSchema();

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

                $inventoryTableName = Import_Module_Model::getInventoryDbTableName($this->user);

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

                        $dbType = $schema->createColumnSchemaBuilder('string', 200);

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

                            $dbType = $schema->createColumnSchemaBuilder($dbType[0], $dbType[1]);

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

                $db->createTable($inventoryTableName, $columns);

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

            ++$this->numberOfRecordsRead;

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

        public $numberOfRecordsRead = 0;

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

        public $request;

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

    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 mixed $fromCharset

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

        }

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

                $columns['relation_id'] = $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 5)->defaultValue(0);

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

                    }

    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

                        $dbType = $schema->createColumnSchemaBuilder($dbType[0], $dbType[1]);

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

                $db->createCommand()->createIndex('id_idx', $inventoryTableName, 'id')->execute();

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

        public function addRecordToDB($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

            $this->user = $user;

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

            $filePath = $this->getFilePath();

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

                $this->errorMessage = 'ERR_CANT_OPEN_FILE';

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

         * @deprecated Use \App\Utils::convertCharacterEncoding()

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

            // Sub-class need to implement this

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

        /**

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

                        $columns[$fieldName] = $field->getDBColumnType();

    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 $db->getLastInsertID($tableName . '_id_seq');

    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 (\in_array($fieldObject->getType(), ['Name', 'Reference', 'Currency'])) {

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

                        if (\is_array($dbType)) {

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

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

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

                    if (\in_array($field->getFieldDataType(), $stringTypes)) {

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

        }

    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

            $this->moduleModel = Vtiger_Module_Model::getInstance($this->request->get('module'));

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

        public function 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

            }

    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

        public function getFileHandler()

    Line exceeds 120 characters; contains 124 characters
    Open

                $columns['relation_id'] = $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 5)->defaultValue(0);

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

                    $dbType = $fieldObject->getDBType();

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

                if ($field = $moduleFields[$fieldName]) {

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

                    'id' => $schema->createColumnSchemaBuilder('integer', 19),

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

                    } elseif (\is_array($dbType)) {

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

            return $this->temp_status;

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

            $db = \App\Db::getInstance();

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

                return true;

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

        public function getFilePath()

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

            }

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

                $columns['src_record'] = 'integer';

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

            }

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

                        $columns[$fieldName] = $schema->createColumnSchemaBuilder('string', 255);

    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

            $this->request = $request;

    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

        public function convertCharacterEncoding($value, $fromCharset, $toCharset)

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

        {

    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

                'temp_status' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 1)->defaultValue(0),

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

                foreach ($inventoryModel->getFields() as $fieldObject) {

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

                    $columns[$fieldObject->getColumnName()] = $dbType;

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

                    }

    Line exceeds 120 characters; contains 158 characters
    Open

                $db->createCommand()->addForeignKey('fk_1_' . $inventoryTableName, $inventoryTableName, 'id', $tableName, 'id', 'CASCADE', 'RESTRICT')->execute();

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

         * Function adds imported inventory data to database.

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

        public function getNumberOfRecordsRead()

    Line exceeds 120 characters; contains 144 characters
    Open

            if ('on' == $this->request->get('has_header') || 1 == $this->request->get('has_header') || true === $this->request->get('has_header')) {

    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

        {

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

            if (!$fileHandler) {

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

        {

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

            $columns = [

    Line exceeds 120 characters; contains 122 characters
    Open

                    $stringTypes = array_merge(Vtiger_Field_Model::$referenceTypes, ['owner', 'currencyList', 'sharedOwner']);

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

         *

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

            $tableName = Import_Module_Model::getDbTableName($this->user);

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

            $db->createCommand()->insert($tableName, $data)->execute();

    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 getStatus()

    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 read()

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

            @unlink($filePath);

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

                'recordid' => 'integer',

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

        {

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

            $db = \App\Db::getInstance();

    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

            return 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

            return $fileHandler;

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

            $db = \App\Db::getInstance();

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

            $tableName = Import_Module_Model::getDbTableName($this->user);

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

                'id' => 'pk',

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

            if ($this->request->getInteger('src_record') && $this->request->getInteger('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

                    foreach ($fieldObject->getCustomColumn() as $name => $dbType) {

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

            return \App\Utils::convertCharacterEncoding($value, $fromCharset, $toCharset);

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

            $filePath = $this->getFilePath();

    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

        {

    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

            $db->createTable($tableName, $columns);

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

                $columns = [

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

                        $columns[$name] = $dbType;

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

                $db->createCommand()->addForeignKey('fk_1_' . $inventoryTableName, $inventoryTableName, 'id', $tableName, 'id', 'CASCADE', 'RESTRICT')->execute();

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

        {

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

         * @param int   $importId

    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

                return 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

                $this->temp_status = 'failed';

    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

                    $stringTypes = array_merge(Vtiger_Field_Model::$referenceTypes, ['owner', 'currencyList', 'sharedOwner']);

    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 $data

    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

                $data['id'] = $importId;

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

                $db->createCommand()->insert($tableName, $data)->execute();

    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 ($inventoryData as $data) {

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

            $tableName = Import_Module_Model::getInventoryDbTableName($this->user);

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

         * @param array $inventoryData

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

        public function addInventoryToDB($inventoryData, $importId)

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

    class Import_FileReader_Reader

    There are no issues that match your filters.

    Category
    Status