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);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method 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);
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);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed. Open
public function createTable()
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Remove error control operator '@' on line 107. Open
public function deleteFile()
{
$filePath = $this->getFilePath();
@unlink($filePath);
}
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'addInventoryToDB'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Utils' in method 'convertCharacterEncoding'. Open
return \App\Utils::convertCharacterEncoding($value, $fromCharset, $toCharset);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'createTable'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Import_Module_Model' in method 'addInventoryToDB'. Open
$tableName = Import_Module_Model::getInventoryDbTableName($this->user);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Import_Module_Model' in method 'addRecordToDB'. Open
$tableName = Import_Module_Model::getDbTableName($this->user);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '130', column '8'). Open
public function createTable()
{
$db = \App\Db::getInstance();
$schema = $db->getSchema();
$tableName = Import_Module_Model::getDbTableName($this->user);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'Import_Module_Model' in method 'createTable'. Open
$inventoryTableName = Import_Module_Model::getInventoryDbTableName($this->user);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'addRecordToDB'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Import_Module_Model' in method 'createTable'. Open
$tableName = Import_Module_Model::getDbTableName($this->user);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Inventory_Model' in method 'createTable'. Open
$inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleModel->getName());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Import_Utils_Helper' in method 'getFilePath'. Open
return Import_Utils_Helper::getImportFilePath($this->user);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method 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();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
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')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "integer" 3 times. Open
'recordid' => 'integer',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Remove the unused function parameter "$hasHeader". Open
public function getFirstRowData($hasHeader = true)
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert($tableName, $data)->execute();
- Exclude checks
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);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert($tableName, $data)->execute();
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public function __construct(App\Request $request, App\User $user)
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->createIndex('id_idx', $inventoryTableName, 'id')->execute();
- Exclude checks
Returning type string
but addRecordToDB()
is declared to return int
Open
return $db->getLastInsertID($tableName . '_id_seq');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->addForeignKey('fk_1_' . $inventoryTableName, $inventoryTableName, 'id', $tableName, 'id', 'CASCADE', 'RESTRICT')->execute();
- Exclude checks
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());
- Exclude checks
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),
- Exclude checks
Call to undeclared method \App\Db::getSchema
Open
$schema = $db->getSchema();
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Import_FileReader_Reader
- Exclude checks
The property $temp_status is not named in camelCase. Open
class Import_FileReader_Reader
{
public $temp_status = 'success';
public $numberOfRecordsRead = 0;
public $errorMessage = '';
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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 = '';
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $moduleModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getErrorMessage()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function adds imported data to database.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Import_Utils_Helper::getImportFilePath($this->user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!file_exists($filePath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->errorMessage = 'ERR_FILE_DOESNT_EXIST';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function deleteFile()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleFields = $this->moduleModel->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $errorMessage = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('on' == $this->request->get('has_header') || 1 == $this->request->get('has_header') || true === $this->request->get('has_header')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->temp_status = 'failed';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileHandler = fopen($filePath, 'r');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $toCharset
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$schema = $db->getSchema();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inventoryTableName = Import_Module_Model::getInventoryDbTableName($this->user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbType = $schema->createColumnSchemaBuilder('string', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbType = $schema->createColumnSchemaBuilder($dbType[0], $dbType[1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createTable($inventoryTableName, $columns);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$this->numberOfRecordsRead;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $numberOfRecordsRead = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $request;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->errorMessage;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $fromCharset
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns['relation_id'] = $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 5)->defaultValue(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleModel->getName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbType = $schema->createColumnSchemaBuilder($dbType[0], $dbType[1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->createIndex('id_idx', $inventoryTableName, 'id')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function addRecordToDB($data)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->user = $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePath = $this->getFilePath();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->errorMessage = 'ERR_CANT_OPEN_FILE';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @deprecated Use \App\Utils::convertCharacterEncoding()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Sub-class need to implement this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns[$fieldName] = $field->getDBColumnType();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $db->getLastInsertID($tableName . '_id_seq');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($fieldObject->getType(), ['Name', 'Reference', 'Currency'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($dbType)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->numberOfRecordsRead;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createTable()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($field->getFieldDataType(), $stringTypes)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->moduleModel->isInventory()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->moduleModel = Vtiger_Module_Model::getInstance($this->request->get('module'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function hasHeader()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldMapping as $fieldName => $index) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFileHandler()
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
$columns['relation_id'] = $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 5)->defaultValue(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbType = $fieldObject->getDBType();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field = $moduleFields[$fieldName]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $schema->createColumnSchemaBuilder('integer', 19),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (\is_array($dbType)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->temp_status;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFilePath()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns['src_record'] = 'integer';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns[$fieldName] = $schema->createColumnSchemaBuilder('string', 255);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct(App\Request $request, App\User $user)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->request = $request;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function convertCharacterEncoding($value, $fromCharset, $toCharset)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldMapping = $this->request->get('field_mapping');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'temp_status' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_SMALLINT, 1)->defaultValue(0),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($inventoryModel->getFields() as $fieldObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns[$fieldObject->getColumnName()] = $dbType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
$db->createCommand()->addForeignKey('fk_1_' . $inventoryTableName, $inventoryTableName, 'id', $tableName, 'id', 'CASCADE', 'RESTRICT')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function adds imported inventory data to database.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getNumberOfRecordsRead()
- Exclude checks
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')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFirstRowData($hasHeader = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fileHandler) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns = [
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$stringTypes = array_merge(Vtiger_Field_Model::$referenceTypes, ['owner', 'currencyList', 'sharedOwner']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = Import_Module_Model::getDbTableName($this->user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert($tableName, $data)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getStatus()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function read()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
@unlink($filePath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'recordid' => 'integer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fileHandler;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = Import_Module_Model::getDbTableName($this->user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => 'pk',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->request->getInteger('src_record') && $this->request->getInteger('relationId')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldObject->getCustomColumn() as $name => $dbType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Utils::convertCharacterEncoding($value, $fromCharset, $toCharset);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePath = $this->getFilePath();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function creates tables for import in database.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createTable($tableName, $columns);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns[$name] = $dbType;
- Exclude checks
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();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $importId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->temp_status = 'failed';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$stringTypes = array_merge(Vtiger_Field_Model::$referenceTypes, ['owner', 'currencyList', 'sharedOwner']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['id'] = $importId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert($tableName, $data)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($inventoryData as $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = Import_Module_Model::getInventoryDbTableName($this->user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $inventoryData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function addInventoryToDB($inventoryData, $importId)
- Exclude checks
Class name "Import_FileReader_Reader" is not in camel caps format Open
class Import_FileReader_Reader
- Exclude checks