Function createXml
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public function createXml($entries, $entriesInventory)
{
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
$xml = new \XMLWriter();
$xml->openMemory();
- 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
Function sanitizeInventoryValue
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function sanitizeInventoryValue($value, $columnName): string
{
if ($field = $this->inventoryFields[$columnName] ?? false) {
if (\in_array($field->getType(), ['Name', 'Reference'])) {
$value = trim($value);
- 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 createXml
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createXml($entries, $entriesInventory)
{
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
$xml = new \XMLWriter();
$xml->openMemory();
Method sanitizeInventoryValue
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sanitizeInventoryValue($value, $columnName): string
{
if ($field = $this->inventoryFields[$columnName] ?? false) {
if (\in_array($field->getType(), ['Name', 'Reference'])) {
$value = trim($value);
Function exportData
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function exportData()
{
$fileName = str_replace(' ', '_', \App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName)));
$entriesInventory = [];
$addInventoryData = $this->fullData && $this->moduleInstance->isInventory();
- 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 method sanitizeInventoryValue() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function sanitizeInventoryValue($value, $columnName): string
{
if ($field = $this->inventoryFields[$columnName] ?? false) {
if (\in_array($field->getType(), ['Name', 'Reference'])) {
$value = trim($value);
- 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
The method createXml() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function createXml($entries, $entriesInventory)
{
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
$xml = new \XMLWriter();
$xml->openMemory();
- 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 34 to the 15 allowed. Open
public function createXml($entries, $entriesInventory)
- 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
Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
public function sanitizeInventoryValue($value, $columnName): string
- 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
Missing class import via use statement (line '149', column '14'). Open
$zip = new ZipArchive();
- 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 '81', column '22'). Open
$dataReader = (new \App\Db\Query())->from($table)->where(['crmid' => $recordData['id']])->orderBy(['seq' => SORT_ASC])->createCommand()->query();
- 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 '182', column '14'). Open
$xml = new \XMLWriter();
- 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
Avoid assigning values to variables in if clauses and the like (line '100', column '7'). Open
public function sanitizeInventoryValue($value, $columnName): string
{
if ($field = $this->inventoryFields[$columnName] ?? false) {
if (\in_array($field->getType(), ['Name', 'Reference'])) {
$value = trim($value);
- 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 '\App\Json' in method 'sanitizeInventoryValue'. Open
$value = \App\Json::encode($valueNewData);
- 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 exportData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->createXml($this->sanitizeValues($row), $entriesInventory);
}
- 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
The method sanitizeInventoryValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = '';
}
- 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 '\App\Config' in method 'createXml'. Open
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
- 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\Purifier' in method 'createXml'. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getBlockName()), $this->moduleName) . '::' . $header;
- 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\Record' in method 'sanitizeInventoryValue'. Open
$displayValue = \App\Record::getLabel($value);
- 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\Language' in method 'createXml'. Open
$xml->writeAttribute('label', \App\Language::translate(html_entity_decode($fieldModel->get('label'), ENT_QUOTES), $this->moduleName));
- 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 '242', column '8'). Open
public function isCData($name, $customColumns = [])
{
if ($customColumns) {
return \array_key_exists($name, $customColumns);
}
- 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 '\App\Fields\Currency' in method 'sanitizeInventoryValue'. Open
}
- 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 createXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$xml->text($this->sanitizeInventoryValue($value, $columnName));
}
- 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 '\App\Language' in method 'exportData'. Open
$fileName = str_replace(' ', '_', \App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName)));
- 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 '214', column '10'). Open
public function createXml($entries, $entriesInventory)
{
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
$xml = new \XMLWriter();
$xml->openMemory();
- 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 '\App\Language' in method 'createXml'. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getBlockName()), $this->moduleName) . '::' . $header;
- 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\Purifier' in method 'exportData'. Open
$fileName = str_replace(' ', '_', \App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName)));
- 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 sanitizeInventoryValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = '';
}
- 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 '\App\Language' in method 'createXml'. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->get('label')), $this->moduleName);
- 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 createXml uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$xml->text($entries[$fieldName]);
}
- 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 '\App\Purifier' in method 'createXml'. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->get('label')), $this->moduleName);
- 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 exportData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->outputFile($fileName);
}
- 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_Inventory_Model' in method 'getEntriesInventory'. Open
$inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleName);
- 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\Record' in method 'sanitizeInventoryValue'. Open
$recordModule = \App\Record::getType($value);
- 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
Define a constant instead of duplicating this literal "label" 4 times. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->get('label')), $this->moduleName);
- 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.
Avoid unused parameters such as '$entries'. Open
public function createXmlFromTemplate($entries, $entriesInventory)
- 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
Avoid unused parameters such as '$entriesInventory'. Open
public function createXmlFromTemplate($entries, $entriesInventory)
- 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
Avoid unused local variables such as '$dataType'. Open
foreach ($fieldModel->getCustomColumn() as $key => $dataType) {
- 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
Call to method writeCData
from undeclared class \XMLWriter
Open
$xml->writeCData($entries[$fieldName]);
- Exclude checks
Call to method startElement
from undeclared class \XMLWriter
Open
$xml->startElement($fieldName);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new \App\Db\Query())->from($table)->where(['crmid' => $recordData['id']])->orderBy(['seq' => SORT_ASC])->createCommand()->query();
- Exclude checks
Call to method startElement
from undeclared class \XMLWriter
Open
$xml->startElement('INVENTORY_ITEMS');
- Exclude checks
Call to method startElement
from undeclared class \XMLWriter
Open
$xml->startElement('INVENTORY_ITEM');
- Exclude checks
Call to method endElement
from undeclared class \XMLWriter
Open
$xml->endElement();
- Exclude checks
Reference to undeclared property \Vtiger_ExportToXml_Model->xmlList
Open
$this->xmlList[] = $this->tmpXmlPath;
- Exclude checks
Reference to undeclared property \Vtiger_ExportToXml_Model->xmlList
Open
$xmlFile = basename($this->xmlList[$i]);
- Exclude checks
Call to method startElement
from undeclared class \XMLWriter
Open
$xml->startElement($columnName);
- Exclude checks
Call to method writeAttribute
from undeclared class \XMLWriter
Open
$xml->writeAttribute('label', \App\Language::translate(html_entity_decode($fieldModel->get('label'), ENT_QUOTES), $this->moduleName));
- Exclude checks
Call to method flush
from undeclared class \XMLWriter
Open
file_put_contents($this->tmpXmlPath, $xml->flush(true), FILE_APPEND);
- Exclude checks
Call to method __construct
from undeclared class \XMLWriter
Open
$xml = new \XMLWriter();
- Exclude checks
Call to method endElement
from undeclared class \XMLWriter
Open
$xml->endElement();
- Exclude checks
Argument 1 (recordId)
is string
but \App\Record::getType()
takes int
defined at /code/app/Record.php:279
Open
$recordModule = \App\Record::getType($value);
- Exclude checks
Reference to undeclared property \Vtiger_ExportToXml_Model->xmlList
Open
$zip->addFile($this->xmlList[$i], $xmlFile);
- Exclude checks
Call to method startDocument
from undeclared class \XMLWriter
Open
$xml->startDocument('1.0', 'UTF-8');
- Exclude checks
Call to method text
from undeclared class \XMLWriter
Open
$xml->text($this->sanitizeInventoryValue($value, $columnName));
- Exclude checks
Call to method text
from undeclared class \XMLWriter
Open
$xml->text($entries[$fieldName]);
- Exclude checks
Call to method endElement
from undeclared class \XMLWriter
Open
$xml->endElement();
- Exclude checks
Reference to undeclared property \Vtiger_ExportToXml_Model->xmlList
Open
array_map('unlink', $this->xmlList);
- Exclude checks
Call to undeclared method \Vtiger_Basic_InventoryField::getCurrencyParam
Open
$valueData = $field->getCurrencyParam([], $value);
- Exclude checks
Reference to undeclared property \Vtiger_ExportToXml_Model->xmlList
Open
$countXmlList = \count($this->xmlList);
- Exclude checks
Call to method writeAttribute
from undeclared class \XMLWriter
Open
$xml->writeAttribute('label', $header);
- Exclude checks
Call to method endElement
from undeclared class \XMLWriter
Open
$xml->endElement();
- Exclude checks
Call to method read
from undeclared class \yii\db\DataReader
Open
while ($row = $dataReader->read()) {
- Exclude checks
Call to method openMemory
from undeclared class \XMLWriter
Open
$xml->openMemory();
- Exclude checks
Call to method setIndent
from undeclared class \XMLWriter
Open
$xml->setIndent(true);
- Exclude checks
Call to method writeAttribute
from undeclared class \XMLWriter
Open
$xml->writeAttribute('type', $fieldModel->getFieldDataType());
- Exclude checks
Call to method endElement
from undeclared class \XMLWriter
Open
$xml->endElement();
- Exclude checks
Call to method startElement
from undeclared class \XMLWriter
Open
$xml->startElement('MODULE_FIELDS');
- Exclude checks
Call to method writeCData
from undeclared class \XMLWriter
Open
$xml->writeCData($this->sanitizeInventoryValue($value, $columnName));
- Exclude checks
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (\in_array($field->getType(), ['Name', 'Reference'])) {
$value = trim($value);
if (!empty($value)) {
$recordModule = \App\Record::getType($value);
$displayValue = \App\Record::getLabel($value);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 152.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_ExportToXml_Model extends \App\Export\Records
- Exclude checks
The class Vtiger_ExportToXml_Model is not named in CamelCase. Open
class Vtiger_ExportToXml_Model extends \App\Export\Records
{
protected $attrList = ['crmfield', 'crmfieldtype', 'partvalue', 'constvalue', 'refmoule', 'spec', 'refkeyfld', 'delimiter', 'testcondition'];
protected $product = false;
protected $tplName = '';
- 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
Spaces must be used to indent lines; tabs are not allowed Open
protected $tplName = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $fileExtension = 'xml';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $inventoryFields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $product = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $tmpXmlPath = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $attrList = ['crmfield', 'crmfieldtype', 'partvalue', 'constvalue', 'refmoule', 'spec', 'refkeyfld', 'delimiter', 'testcondition'];
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
protected $attrList = ['crmfield', 'crmfieldtype', 'partvalue', 'constvalue', 'refmoule', 'spec', 'refkeyfld', 'delimiter', 'testcondition'];
- 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->tplName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->createXmlFromTemplate($row, $entriesInventory);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inventoryModel = Vtiger_Inventory_Model::getInstance($this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->inventoryFields = $inventoryModel->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
* Sanitize inventory value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$displayValue = \App\Record::getLabel($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$countXmlList = \count($this->xmlList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xmlFile = explode('_', $xmlFile);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entriesInventory = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 < $count) {
- 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
$table = $inventoryModel->getDataTableName();
- 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
$value = $recordModule . '::::' . $displayValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-type: application/zip');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink($zipName);
- 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 setTemplate(string $tplName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$count;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($field->getType(), ['Name', 'Reference'])) {
- 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 html_entity_decode($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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->setIndent(true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$fileName = str_replace(' ', '_', \App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->tmpXmlPath = 'cache/import/' . uniqid() . '_.xml';
- 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
$entries = [];
- 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
readfile($zipName);
- 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
* Set template.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipName = 'cache/import/' . uniqid() . '.zip';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 0; $i < $countXmlList; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('cache-control: post-check=0, pre-check=0', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$addInventoryData = $this->fullData && $this->moduleInstance->isInventory();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns data from advanced block.
- 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
public function getEntriesInventory($recordData): array
- 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
header('content-type: text/csv;charset=UTF-8');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
readfile($this->tmpXmlPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header("content-disposition: attachment;filename=$fileName.zip");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->startDocument('1.0', 'UTF-8');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = str_replace(' ', '_', \App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entriesInventory = $this->getEntriesInventory($row) ?: [];
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
$dataReader = (new \App\Db\Query())->from($table)->where(['crmid' => $recordData['id']])->orderBy(['seq' => SORT_ASC])->createCommand()->query();
- 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
$recordModule = \App\Record::getType($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valueData = $field->getCurrencyParam([], $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = \App\Json::encode($valueNewData);
- 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
header("content-disposition: attachment;filename=$fileName.xml");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $entries
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
- 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
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->xmlList[] = $this->tmpXmlPath;
- 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
$dataReader = (new \App\Db\Query())->from($table)->where(['crmid' => $recordData['id']])->orderBy(['seq' => SORT_ASC])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($inventoryRow = $dataReader->read()) {
- 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 $columnName
- 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
$value = $field->getDisplayValue($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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('currencyparam' === $columnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valueNewData = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($valueData as $currencyId => &$data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('cache-control: post-check=0, pre-check=0', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->open($zipName, ZipArchive::CREATE);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('expires: Mon, 31 Dec 2000 00:00:00 GMT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $tplName
- 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->tplName = $tplName;
- 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
$count = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->createXml($this->sanitizeValues($row), $entriesInventory);
- 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
if (!empty($recordModule) && !empty($displayValue)) {
- 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 outputFile($fileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = new ZipArchive();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xmlFile = basename($this->xmlList[$i]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_shift($xmlFile);
- 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
* Create XML file.
- 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
$dataReader = $this->getExportQuery()->createCommand()->query();
- 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
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($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
$xmlFile = $fileName . $i . implode('_', $xmlFile);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createXml($entries, $entriesInventory)
- 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 $entries;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = trim($value);
- 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
} elseif ('Currency' === $field->getType()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valueNewData[$currencyName] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink($this->tmpXmlPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_map('unlink', $this->xmlList);
- 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
$xml = new \XMLWriter();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($addInventoryData) {
- 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
$this->outputZipFile($fileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $recordData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entries[] = $inventoryRow;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function sanitizeInventoryValue($value, $columnName): 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
if ($field = $this->inventoryFields[$columnName] ?? 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
} elseif (\in_array($columnName, ['taxparam', 'discountparam', 'currencyparam'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencyName = \App\Fields\Currency::getById($currencyId)['currency_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['value'] = $currencyName;
- 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
$value = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = $this->inventoryFields['currency'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('expires: Mon, 31 Dec 2000 00:00:00 GMT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $entriesInventory
- 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
$xml->openMemory();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function exportData()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputFile($fileName);
- 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
protected function outputZipFile($fileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->addFile($this->xmlList[$i], $xmlFile);
- 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
$xml->endElement();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \array_key_exists($name, $customColumns);
- 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 createXmlFromTemplate($entries, $entriesInventory)
- 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
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getBlockName()), $this->moduleName) . '::' . $header;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($entriesInventory) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($fieldModel = $this->moduleFieldInstances[$name] ?? false) && \in_array($fieldModel->getFieldDataType(), ['text', 'multiEmail'])) {
- 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 ($fieldModel->get('source_field_name')) {
- 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
$xml->text($this->sanitizeInventoryValue($value, $columnName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->endElement();
- 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
$xml->writeAttribute('type', $fieldModel->getFieldDataType());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->writeAttribute('label', $header);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->text($entries[$fieldName]);
- 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
$xml->startElement('INVENTORY_ITEM');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->fields as $fieldName => $fieldModel) {
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getBlockName()), $this->moduleName) . '::' . $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
if (!\in_array($columnName, $customColumns)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->isCData($columnName, $customColumns)) {
- 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 isCData($name, $customColumns = [])
- 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
$xml->startElement($columnName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->startElement($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->writeCData($entries[$fieldName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customColumns = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($inventory as $columnName => $value) {
- 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
$xml->endElement();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->endElement();
- 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
$xml->startElement('INVENTORY_ITEMS');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->writeAttribute('label', \App\Language::translate(html_entity_decode($fieldModel->get('label'), ENT_QUOTES), $this->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 false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->startElement('MODULE_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
file_put_contents($this->tmpXmlPath, $xml->flush(true), FILE_APPEND);
- 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 ($exportBlockName) {
- 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
if ($fieldModel = ($this->inventoryFields[$columnName] ?? false)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($customColumns) {
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
if (($fieldModel = $this->moduleFieldInstances[$name] ?? false) && \in_array($fieldModel->getFieldDataType(), ['text', 'multiEmail'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->get('label')), $this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->isCData($fieldName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($inventory['id'], $inventory['crmid']);
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
$xml->writeAttribute('label', \App\Language::translate(html_entity_decode($fieldModel->get('label'), ENT_QUOTES), $this->moduleName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$customColumns[$key] = $columnName;
- 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
$xml->writeCData($this->sanitizeInventoryValue($value, $columnName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xml->endElement();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($entriesInventory as $inventory) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldModel->getCustomColumn() as $key => $dataType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "Vtiger_ExportToXml_Model" is not in camel caps format Open
class Vtiger_ExportToXml_Model extends \App\Export\Records
- Exclude checks