Function getListTplForXmlType
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function getListTplForXmlType($moduleName)
{
$output = [];
$path = 'modules/Import/tpl/';
if (is_dir($path)) {
- 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
Consider simplifying this complex logical expression. Open
if ($moduleField->isActiveField() &&
'vtiger_entity_stats' !== $moduleField->getTableName() &&
!\in_array($moduleField->getColumnName(), ['modifiedby', 'modifiedtime']) &&
!\in_array($moduleField->getUIType(), [70, 4]) &&
0 !== strcasecmp($moduleField->getFieldDataType(), 'autogenerated') &&
Function getFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getFields($blockInstance = false)
{
if (empty($this->fields)) {
$moduleModel = $this->getImportModuleModel();
$this->fields = [];
- 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
The class Import_Module_Model has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13. Open
class Import_Module_Model extends Vtiger_Module_Model
{
/**
* Import table prefix.
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '282', column '16'). Open
return (new \App\Db\Query())->from($tableName)->where(['temp_status' => Import_Data_Action::IMPORT_RECORD_NONE])->exists();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '145', column '16'). Open
$list = new DirectoryIterator($path);
- Read upRead up
- Exclude checks
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 getFields has a boolean flag argument $blockInstance, which is a certain sign of a Single Responsibility Principle violation. Open
public function getFields($blockInstance = false)
- 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
The method getUrl uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$url = $this->getImportModuleModel()->getListViewUrl();
}
- 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
Avoid using static access to class 'Vtiger_Relation_Model' in method 'getUrl'. Open
if ($this->get('relationId') && $this->get('src_record') && $relationModel = Vtiger_Relation_Model::getInstanceById($this->get('relationId'))) {
- 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 'vtlib\Utils' in method 'isUserImportBlocked'. Open
if (vtlib\Utils::checkTable($tableName)) {
- 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 'clearUserImportInfo'. 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 assigning values to variables in if clauses and the like (line '312', column '63'). Open
public function getUrl()
{
if ($this->get('relationId') && $this->get('src_record') && $relationModel = Vtiger_Relation_Model::getInstanceById($this->get('relationId'))) {
$url = $relationModel->getListUrl(Vtiger_Record_Model::getInstanceById($this->get('src_record')));
} else {
- 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 assigning values to variables in if clauses and the like (line '169', column '7'). Open
public static function getFileReader(App\Request $request, App\User $user)
{
$type = $request->get('type');
if ($componentName = static::$componentReader[$type]) {
$modelClassName = Vtiger_Loader::getComponentClassName('Reader', $componentName, 'Import');
- 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
The method getDbTableName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$tableName .= $user->id;
}
- 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
Avoid using static access to class 'Import_Queue_Action' in method 'clearUserImportInfo'. Open
Import_Queue_Action::removeForUser($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_Lock_Action' in method 'clearUserImportInfo'. Open
Import_Lock_Action::unLock($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_Module_Model' in method 'getImportModuleModel'. Open
return $this->importModuleModel = Vtiger_Module_Model::getInstance($this->getImportModule());
- 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_Record_Model' in method 'getUrl'. Open
$url = $relationModel->getListUrl(Vtiger_Record_Model::getInstanceById($this->get('src_record')));
- 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_Loader' in method 'getFileReader'. Open
$modelClassName = Vtiger_Loader::getComponentClassName('Reader', $componentName, 'Import');
- 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 unused parameters such as '$blockInstance'. Open
public function getFields($blockInstance = false)
- 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
Returning type array{,:'comma',;:'semicolon'}
but getSupportedDelimiters()
is declared to return \type
Open
return self::$supportedDelimiters;
- Exclude checks
Doc-block of $moduleName
in getSupportedFileExtensions
is phpdoc param type string
which is not a permitted replacement of the nullable param type ?string
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param string $moduleName
- Exclude checks
Return type of getSupportedDelimiters()
is undeclared type \type
Open
public static function getSupportedDelimiters()
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new \App\Db\Query())->from($tableName)->where(['temp_status' => Import_Data_Action::IMPORT_RECORD_NONE])->exists();
- Exclude checks
Argument 2 (needle)
is \type
but \strpos()
takes int|string
Open
if (0 === strpos($fileName, $moduleName)) {
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->dropTable($table)->execute();
- Exclude checks
Return type of getSupportedFileEncoding()
is undeclared type \type
Open
public static function getSupportedFileEncoding()
- Exclude checks
Returning type array{UTF-8:'UTF-8',ISO-8859-1:'ISO-8859-1',Windows-1250:'Windows-1250',Windows-1251:'Windows-1251',Windows-1252:'Windows-1252',Windows-1253:'Windows-1253',Windows-1254:'Windows-1254',Windows-1255:'Windows-1255',Windows-1256:'Windows-1256',Windows-1257:'Windows-1257',Windows-1258:'Windows-1258'}
but getSupportedFileEncoding()
is declared to return \type
Open
return self::$supportedFileEncoding;
- Exclude checks
Returning type null
but getFileReader()
is declared to return \Import_FileReader_Reader
Open
return null;
- Exclude checks
Parameter $moduleName
has undeclared type \type
Open
public static function getListTplForXmlType($moduleName)
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public static function getFileReader(App\Request $request, App\User $user)
- Exclude checks
Call to undeclared method \App\Db::getTableSchema
Open
if (!empty($db->getTableSchema($table, true))) {
- Exclude checks
Avoid excessively long variable names like $supportedFileExtensions. Keep variable name length under 20. Open
public static $supportedFileExtensions = ['csv', 'vcf', 'ical', 'xml', 'ics'];
- Read upRead up
- Exclude checks
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
Avoid excessively long variable names like $supportedFileExtensionsByModule. Keep variable name length under 20. Open
public static $supportedFileExtensionsByModule = ['Contacts' => ['csv', 'vcf', 'xml', 'zip'], 'Calendar' => ['csv', 'ical', 'ics', 'xml'], 'Default' => ['csv', 'xml', 'zip']];
- Read upRead up
- Exclude checks
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
Avoid excessively long variable names like $supportedFileEncoding. Keep variable name length under 20. Open
public static $supportedFileEncoding = [
'UTF-8' => 'UTF-8',
'ISO-8859-1' => 'ISO-8859-1',
'Windows-1250' => 'Windows-1250',
'Windows-1251' => 'Windows-1251',
- Read upRead up
- Exclude checks
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_Module_Model extends Vtiger_Module_Model
- Exclude checks
The class Import_Module_Model is not named in CamelCase. Open
class Import_Module_Model extends Vtiger_Module_Model
{
/**
* Import table prefix.
*
- 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
Terminating statement must be indented to the same level as the CASE body Open
return self::$supportedFileExtensionsByModule[$moduleName];
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return self::$supportedFileExtensionsByModule['Default'];
- 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
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xml' => 'XmlReader',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ISO-8859-1' => 'ISO-8859-1',
- 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
'default' => 'FileReader',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $supportedFileEncoding = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ics' => 'ICSReader',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const AUTO_MERGE_EXISTINGISPRIORITY = 4;
- 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
* Auto marge state.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'zip' => 'ZipReader',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Windows-1252' => 'Windows-1252',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ical' => 'ICSReader',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Windows-1254' => 'Windows-1254',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Windows-1255' => 'Windows-1255',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const IMPORT_TABLE_PREFIX = 'u_yf_import_';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const AUTO_MERGE_NONE = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'csv' => 'CSVReader',
- 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
'Windows-1250' => 'Windows-1250',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Windows-1253' => 'Windows-1253',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Import table prefix.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Components name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $componentReader = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vcf' => 'VCardReader',
- 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
const AUTO_MERGE_IGNORE = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const AUTO_MERGE_MERGEFIELDS = 3;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'UTF-8' => 'UTF-8',
- 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
'Windows-1251' => 'Windows-1251',
- 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
const AUTO_MERGE_OVERWRITE = 2;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($supportedFileTypes as $fileType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::AUTO_MERGE_IGNORE => 'Skip',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- 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->fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $supportedFileExtensionsByModule = ['Contacts' => ['csv', 'vcf', 'xml', 'zip'], 'Calendar' => ['csv', 'ical', 'ics', 'xml'], 'Default' => ['csv', 'xml', 'zip']];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$output = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_dir($path)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getFileReader(App\Request $request, App\User $user)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
!\in_array($moduleField->getUIType(), [70, 4]) &&
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
0 !== strcasecmp($moduleField->getFieldDataType(), 'autogenerated') &&
- 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
case 'Contacts':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return implode(', ', $description);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedFileEncoding()
- 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
if ($componentName = static::$componentReader[$type]) {
- 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 ($moduleModel->getFields() as $moduleField) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedDelimiters()
- 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 static $supportedDelimiters = [',' => 'comma', ';' => 'semicolon'];
- Exclude checks
Line exceeds 120 characters; contains 179 characters Open
public static $supportedFileExtensionsByModule = ['Contacts' => ['csv', 'vcf', 'xml', 'zip'], 'Calendar' => ['csv', 'ical', 'ics', 'xml'], 'Default' => ['csv', 'xml', 'zip']];
- 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
self::AUTO_MERGE_OVERWRITE => 'Overwrite',
- 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
'Windows-1257' => 'Windows-1257',
- 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 self::$supportedDelimiters;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::AUTO_MERGE_EXISTINGISPRIORITY => 'LBL_FILL_EMPTY'
- 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
0 !== strcasecmp($moduleField->getFieldDataType(), 'id')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set import module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$description[] = '.' . strtoupper($fileType);
- 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
$type = $request->get('type');
- 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 string $moduleName
- 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
$modelClassName = Vtiger_Loader::getComponentClassName('Reader', $componentName, 'Import');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $blockInstance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Vtiger_Field_Model[] - list of field models
- 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 $importModule;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $importModuleModel;
- 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 self::$supportedFileExtensionsByModule[$moduleName];
- 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 $output;
- 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
{
- 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
'Windows-1256' => 'Windows-1256',
- 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 self::$supportedFileExtensions;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$supportedFileExtensionsByModule['Default'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getListTplForXmlType($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$singleFile->isDot()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === strpos($fileName, $moduleName)) {
- 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
if (empty($this->fields)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $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
*/
- 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
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Calendar':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedFileExtensionsDescription($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$supportedFileTypes = self::getSupportedFileExtensions($moduleName);
- 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
* Function that returns all the fields for the 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
$moduleModel = $this->getImportModuleModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $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
if (vtlib\Utils::checkTable($tableName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Windows-1258' => 'Windows-1258',
- 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
$description = [];
- 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
self::AUTO_MERGE_MERGEFIELDS => 'Merge',
- 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 returns list of templates to import.
- 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 (!$moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($moduleName) {
- 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
$path = 'modules/Import/tpl/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $singleFile->getFilename();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new $modelClassName($request, $user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFields($blockInstance = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
!\in_array($moduleField->getColumnName(), ['modifiedby', 'modifiedtime']) &&
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param type $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$list = new DirectoryIterator($path);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($moduleField->isActiveField() &&
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_entity_stats' !== $moduleField->getTableName() &&
- 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 static function getDbTableName($user)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns name of the table to import for data from advanced block.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = self::getDbTableName($user);
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
return (new \App\Db\Query())->from($tableName)->where(['temp_status' => Import_Data_Action::IMPORT_RECORD_NONE])->exists();
- 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
Import_Lock_Action::unLock($user);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->get('relationId') && $this->get('src_record') && $relationModel = Vtiger_Relation_Model::getInstanceById($this->get('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
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns supported extensions.
- 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 static function getAutoMergeTypes()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$output[] = $fileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get file reader.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->fields;
- 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 getImportModuleModel()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->importModuleModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Import_Queue_Action::removeForUser($user);
- 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 returns instance of the module where import takes place.
- 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
} elseif (method_exists($user, 'getId')) {
- 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
public static $supportedFileExtensions = ['csv', 'vcf', 'ical', 'xml', 'ics'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns supported extensions.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedFileExtensions(?string $moduleName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns supported extensions.
- 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 self::$supportedFileEncoding;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get supported delimiters.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($list as $singleFile) {
- 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
* @return \Import_FileReader_Reader
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->fields[$moduleField->get('name')] = $moduleField;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setImportModule($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->importModule = $moduleName;
- 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 getImportModule()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->importModuleModel = Vtiger_Module_Model::getInstance($this->getImportModule());
- 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
* Function checks if import is blocked for user.
- 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 ($tables as $table) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->dropTable($table)->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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($user)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName .= $user->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName .= $user->id;
- 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 $tableName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tables = [self::getInventoryDbTableName($user), self::getDbTableName($user)];
- 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
$tableName = self::IMPORT_TABLE_PREFIX;
- 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 (!empty($db->getTableSchema($table, 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
* Get callback url.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = $relationModel->getListUrl(Vtiger_Record_Model::getInstanceById($this->get('src_record')));
- 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 Vtiger_Module_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->importModuleModel) {
- 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 string
- 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
return self::getDbTableName($user) . '_inv';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function isUserImportBlocked($user)
- 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
$url = $this->getImportModuleModel()->getListViewUrl();
- 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 $user
- 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 static function clearUserImportInfo($user)
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns name of the table to import.
- 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 clears data related to import of records by user.
- 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
* Function returns module name where import takes place.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName .= $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- 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 mixed $user
- 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 static function getInventoryDbTableName($user)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
if ($this->get('relationId') && $this->get('src_record') && $relationModel = Vtiger_Relation_Model::getInstanceById($this->get('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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->from($tableName)->where(['temp_status' => Import_Data_Action::IMPORT_RECORD_NONE])->exists();
- 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 $user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $url;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->importModule;
- 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
Class name "Import_Module_Model" is not in camel caps format Open
class Import_Module_Model extends Vtiger_Module_Model
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'Calendar':
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'Contacts':
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
default:
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
}
- Exclude checks
Closing brace indented incorrectly; expected 8 spaces, found 12 Open
}
- Exclude checks