sendHttpHeader accesses the super-global variable $_SERVER. Open
public function sendHttpHeader(): void
{
header("content-disposition: attachment; filename=\"{$this->getFileName()}\"");
header("content-type: {$this->getExportContentType()}; charset=UTF-8");
header('expires: Mon, 31 Dec 2000 00:00:00 GMT');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
sendHttpHeader accesses the super-global variable $_SERVER. Open
public function sendHttpHeader(): void
{
header("content-disposition: attachment; filename=\"{$this->getFileName()}\"");
header("content-type: {$this->getExportContentType()}; charset=UTF-8");
header('expires: Mon, 31 Dec 2000 00:00:00 GMT');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Function sanitizeInventoryValues
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function sanitizeInventoryValues(array $inventoryRow, array $inventoryFields): array
{
$inventoryEntries = [];
foreach ($inventoryFields as $columnName => $field) {
$value = $inventoryRow[$columnName];
- 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 Records has an overall complexity of 71 which is very high. The configured complexity threshold is 50. Open
abstract class Records extends \App\Base
{
/** @var int Data export in a format that can be imported later */
public const EXPORT_FORMAT = 0;
- Exclude checks
File Records.php
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Abstract base view controller file.
*
* @package Export
Records
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Records extends \App\Base
{
/** @var int Data export in a format that can be imported later */
public const EXPORT_FORMAT = 0;
Method sanitizeInventoryValues
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sanitizeInventoryValues(array $inventoryRow, array $inventoryFields): array
{
$inventoryEntries = [];
foreach ($inventoryFields as $columnName => $field) {
$value = $inventoryRow[$columnName];
Function getAllModuleFieldsAsHeaders
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getAllModuleFieldsAsHeaders(): array
{
$headers = [];
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
foreach ($this->moduleFieldInstances as $fieldModel) {
- 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 setField
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setField(string $fieldName)
{
$fieldModel = null;
[$relatedFieldName, $relatedModule, $referenceField] = array_pad(explode(':', $fieldName), 3, null);
- 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 getDisplayValue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getDisplayValue(\Vtiger_Field_Model $fieldModel, $value, int $recordId, array $rowData, $length = 65000)
Function getHeaders
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getHeaders(): array
{
if (!$this->headers) {
if ($this->fullData) {
$this->headers = $this->getAllModuleFieldsAsHeaders();
- 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 sanitizeInventoryValues() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function sanitizeInventoryValues(array $inventoryRow, array $inventoryFields): array
{
$inventoryEntries = [];
foreach ($inventoryFields as $columnName => $field) {
$value = $inventoryRow[$columnName];
- 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
Class "Records" has 21 methods, which is greater than 20 authorized. Split it into smaller classes. Open
abstract class Records extends \App\Base
- Read upRead up
- Exclude checks
A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.
Refactor this function to reduce its Cognitive Complexity from 28 to the 15 allowed. Open
public function sanitizeInventoryValues(array $inventoryRow, array $inventoryFields): array
- 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
The class Records has a coupling between objects value of 18. Consider to reduce the number of dependencies under 13. Open
abstract class Records extends \App\Base
{
/** @var int Data export in a format that can be imported later */
public const EXPORT_FORMAT = 0;
- 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 '177', column '15'). Open
throw new \App\Exceptions\IllegalValue("ERR_FIELD_NOT_FOUND||{$relatedFieldName}");
- 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 '77', column '35'). Open
$instance->queryGenerator = new \App\QueryGenerator($moduleName);
- 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 '155', column '9'). Open
public function loadFieldsFromCvId(int $cvId): void
{
foreach (\App\CustomView::getInstance($this->moduleName)->getColumnsListByCvid($cvId) as $fieldInfo) {
['field_name' => $relatedFieldName, 'module_name' => $relatedModule, 'source_field_name' => $referenceField] = $fieldInfo;
$cvFieldData = $referenceField ? "{$relatedFieldName}:{$relatedModule}:{$referenceField}" : $relatedFieldName;
- 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 'getAllModuleFieldsAsHeaders'. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getFieldLabel()), $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 'sanitizeInventoryValues'. 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
Avoid using static access to class '\App\Fields\SharedOwner' in method 'getDisplayValue'. Open
$value = implode(',', \App\Fields\SharedOwner::getById($recordId));
- 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 setField uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result = false;
}
- 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 'getAllModuleFieldsAsHeaders'. Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getFieldLabel()), $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\Json' in method 'sanitizeInventoryValues'. Open
$valueParam = \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
Avoid using static access to class '\App\Record' in method 'sanitizeInventoryValues'. 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\Purifier' in method 'getFileName'. Open
return \App\Utils::sanitizeSpecialChars(\App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName))) . ".{$this->fileExtension}";
- 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 'getFileName'. Open
return \App\Utils::sanitizeSpecialChars(\App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName))) . ".{$this->fileExtension}";
- 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 'getAllModuleFieldsAsHeaders'. Open
$headers[] = 'Inventory::' . \App\Language::translate(\App\Purifier::decodeHtml($field->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
Avoid using static access to class '\Vtiger_Module_Model' in method 'getInstance'. Open
$instance->moduleInstance = \Vtiger_Module_Model::getInstance($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\Fields\File' in method 'getExportContentType'. Open
return \App\Fields\File::getMimeContentType($this->getFileName());
- 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 'getHeaders'. Open
$this->headers[] = \App\Purifier::decodeHtml($label);
- 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 'getAllModuleFieldsAsHeaders'. Open
$headers[] = 'Inventory::' . \App\Language::translate(\App\Purifier::decodeHtml($field->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
Avoid using static access to class '\Vtiger_Loader' in method 'getInstance'. Open
$modelClassName = \Vtiger_Loader::getComponentClassName('Model', $componentName, $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 sanitizeValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$valuesToReturn = $this->getDataInExportFormat($recordValues);
}
- 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 getHeaders uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($this->fields as $fieldModel) {
$label = $fieldModel->getFullLabelTranslation($this->moduleInstance);
$this->headers[] = \App\Purifier::decodeHtml($label);
}
- 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 'getAllModuleFieldsAsHeaders'. 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\Utils' in method 'getFileName'. Open
return \App\Utils::sanitizeSpecialChars(\App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName))) . ".{$this->fileExtension}";
- 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\Config' in method 'getSupportedFileFormats'. Open
return \App\Config::module($moduleName, 'EXPORT_SUPPORTED_FILE_FORMATS') ?? [
- 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 'getAllModuleFieldsAsHeaders'. 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 '\Vtiger_Inventory_Model' in method 'getAllModuleFieldsAsHeaders'. 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
The method sanitizeInventoryValues 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\Fields\Currency' in method 'sanitizeInventoryValues'. 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
Avoid using static access to class '\App\Purifier' in method 'getDisplayValue'. Open
$returnValue = \App\Purifier::decodeHtml($returnValue);
- 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 getInstance uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$componentName = 'ExportTo' . ucfirst($exportType);
}
- 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 'getAllModuleFieldsAsHeaders'. 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
The method sanitizeInventoryValues 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
Define a constant instead of duplicating this literal "label" 4 times. Open
if (($fieldModel = $this->setField($cvFieldData)) && $fieldInfo['label']) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "source_field_name" 6 times. Open
['field_name' => $relatedFieldName, 'module_name' => $relatedModule, 'source_field_name' => $referenceField] = $fieldInfo;
- 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.
Rename "$headers" which has the same name as the field declared at line 39. Open
$headers = [];
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Avoid unused local variables such as '$dbType'. Open
foreach ($field->getCustomColumn() as $columnName => $dbType) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$dbType'. Open
foreach ($field->getCustomColumn() as $customColumnName => $dbType) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$rowData'. Open
public function getDisplayValue(\Vtiger_Field_Model $fieldModel, $value, int $recordId, array $rowData, $length = 65000)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Call to method set
from undeclared class \App\Export\Vtiger_Field_Model
Open
$fieldModel->set('label', $fieldInfo['label']);
- Exclude checks
Reference to undeclared property \App\Export\Records->queryGenerator
Open
return $this->queryGenerator;
- Exclude checks
Call to method set
from undeclared class \App\Export\Vtiger_Field_Model
Open
$fieldModel->set('isLabelCustomized', true);
- Exclude checks
Return type of getInstance()
is undeclared type \self
Open
public static function getInstance(string $moduleName, string $exportType = 'csv')
- Exclude checks
Return type of getQueryGenerator()
is undeclared type \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
public function getQueryGenerator(): \App\QueryGenerator
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields(['id'])->addCondition('id', 0, 'e');
- Exclude checks
Call to deprecated function \Vtiger_Field_Model::getFieldLabel()
defined at /code/modules/Vtiger/models/Field.php:215
Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getFieldLabel()), $this->moduleName);
- Exclude checks
Call to method clearFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->clearFields()->setLimit($this->limit);
- Exclude checks
Saw an @param annotation for moduleName,
but the param list of function getFileName() : string
is empty Open
* @param string $moduleName
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$instance->queryGenerator = new \App\QueryGenerator($moduleName);
- Exclude checks
Assigning int
to property but \App\Export\Records->format
is bool
Open
protected $format = self::EXPORT_FORMAT;
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
return $queryGenerator->createQuery();
- Exclude checks
Return type of setField()
is undeclared type \App\Export\Vtiger_Field_Model
Open
public function setField(string $fieldName)
- Exclude checks
Call to method setField
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setField($fieldName);
- 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
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ('currencyparam' === $customColumnName) {
$field = $inventoryFields['currency'];
$valueData = $field->getCurrencyParam([], $valueParam);
if (\is_array($valueData)) {
$valueNewData = [];
- 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 108.
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
Spaces must be used to indent lines; tabs are not allowed Open
public const EXPORT_FORMAT = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new $modelClassName();
- 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 ($fields as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cvFieldData = $referenceField ? "{$relatedFieldName}:{$relatedModule}:{$referenceField}" : $relatedFieldName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $fullData = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$componentName = 'ExportToCsv';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get supported file formats.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_XML' => 'xml',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get query generator object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->queryGenerator;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Data export in user format */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \Vtiger_Module_Model Module model. */
- 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 getQueryGenerator(): \App\QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $fields
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Module name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $moduleFieldInstances;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string File extension */
- 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
* Set the format of the exported data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
abstract public function exportData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setField($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
* @return void
- 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 setFields(array $fields)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $cvId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($fieldModel = $this->setField($cvFieldData)) && $fieldInfo['label']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const USER_FORMAT = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Fields for export */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get instance.
- 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
$modelClassName = \Vtiger_Loader::getComponentClassName('Model', $componentName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->fileExtension = $exportType;
- 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
$fieldModel->set('isLabelCustomized', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $headers = [];
- 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
$instance->queryGenerator = new \App\QueryGenerator($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- 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
'LBL_XLS' => 'xls',
- 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 $fileExtension = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Headers field */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Export all data */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance(string $moduleName, string $exportType = 'csv')
- 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
* Function exports the data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function loadFieldsFromCvId(int $cvId): void
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$cvFieldData = $referenceField ? "{$relatedFieldName}:{$relatedModule}:{$referenceField}" : $relatedFieldName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Data export in a format that can be imported later */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \Vtiger_Field_Model[] Field model instance. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$componentName = 'ExportToSpreadsheet';
- 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
protected $format = self::EXPORT_FORMAT;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $exportType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- 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 $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\App\CustomView::getInstance($this->moduleName)->getColumnsListByCvid($cvId) as $fieldInfo) {
- 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 ('csv' === $exportType || empty($exportType)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('xls' === $exportType || 'xlsx' === $exportType || 'ods' === $exportType) {
- 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
* @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
* Set.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Export all data */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSupportedFileFormats(string $moduleName): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Config::module($moduleName, 'EXPORT_SUPPORTED_FILE_FORMATS') ?? [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $format self::EXPORT_FORMAT or self::USER_FORMAT
- 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
['field_name' => $relatedFieldName, 'module_name' => $relatedModule, 'source_field_name' => $referenceField] = $fieldInfo;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$componentName = 'ExportTo' . ucfirst($exportType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->moduleName = $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->format = $format;
- 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 $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
$instance->moduleFieldInstances = $instance->moduleInstance->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load fields from custom view.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
['field_name' => $relatedFieldName, 'module_name' => $relatedModule, 'source_field_name' => $referenceField] = $fieldInfo;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $moduleInstance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Limit of exported entries */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $limit;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->moduleInstance = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_CSV' => 'csv',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setFormat(int $format)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \App\QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Vtiger_Field_Model|false
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue("ERR_FIELD_NOT_FOUND||{$relatedFieldName}");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $result;
- 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 a limit for exported data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get fields for 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
if ($this->moduleInstance->isInventory()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->headers[] = \App\Purifier::decodeHtml($label);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->headers;
- 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 (self::USER_FORMAT === $this->format) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $inventoryRow
- 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 (!$this->headers) {
- 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
$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
foreach ($inventoryFields as $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$headers[] = 'Inventory::' . $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
public function sanitizeValues(array $recordValues): 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
$fieldModel = clone $relatedFieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $this->fields[$fieldModel->getFullName()] = $fieldModel;
- 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->limit = $limit;
- 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 array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->moduleFieldInstances as $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$headers[] = 'Inventory::recordIteration';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setField(string $fieldName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $limit
- 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 ($this->fields as $fieldModel) {
- 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
Line exceeds 120 characters; contains 138 characters Open
$headers[] = 'Inventory::' . \App\Language::translate(\App\Purifier::decodeHtml($field->get('label')), $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
$queryGenerator->setField($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This function takes in an array of values for an user and sanitizes it for export
- 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
$result = 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
$label = $fieldModel->getFullLabelTranslation($this->moduleInstance);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$headers = [];
- 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
$queryGenerator->setFields(['id'])->addCondition('id', 0, 'e');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 147 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
}
- 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 (array_keys($queryFields) as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valuesToReturn = $this->getDataInUserFormat($recordValues);
- 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 $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->fullData) {
- 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
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getFieldLabel()), $this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$headers[] = $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
$inventoryFields = $inventoryModel->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($field->getCustomColumn() as $columnName => $dbType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \App\Db\Query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$relatedFieldName, $relatedModule, $referenceField] = array_pad(explode(':', $fieldName), 3, null);
- 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 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
public function getExportQuery(): \App\Db\Query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $queryGenerator->createQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Requires modification after adding a new field type.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valuesToReturn = $this->getDataInExportFormat($recordValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('label', $fieldInfo['label']);
- 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 (!empty($this->moduleFieldInstances[$relatedFieldName])) {
- 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->headers = $this->getAllModuleFieldsAsHeaders();
- 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->setFields(array_keys($this->moduleFieldInstances));
- 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
* @param array $inventoryFields
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set field model.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->moduleFieldInstances[$referenceField]) || !$relatedFieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel && $fieldModel->isExportable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$headers[] = 'Inventory::' . \App\Language::translate(\App\Purifier::decodeHtml($field->get('label')), $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
} 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 ($referenceField) {
- 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
{
- 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 all module fields as headers.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exportBlockName = \App\Config::component('Export', 'BLOCK_NAME');
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$header = \App\Language::translate(\App\Purifier::decodeHtml($fieldModel->getFieldLabel()), $this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $headers;
- 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
$relatedFieldModel = \Vtiger_Module_Model::getInstance($relatedModule)->getFieldByName($relatedFieldName);
- 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
public function setLimit(int $limit)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getHeaders(): 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
if ($this->fullData) {
- 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 ($fieldModel->isExportable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->clearFields()->setLimit($this->limit);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$queryFields) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sanitize inventory values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = clone $this->moduleFieldInstances[$relatedFieldName];
- 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
$queryGenerator = $this->getQueryGenerator();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryFields = $this->getFieldsForQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $recordValues
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $valuesToReturn;
- 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 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
$displayValue = \App\Record::getLabel($value);
- 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
$value = $recordModule . '::::' . $displayValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valueData = $field->getCurrencyParam([], $valueParam);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$inventoryEntries['inv_' . $customColumnName] = $valueParam;
- 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 getDataInUserFormat(array $recordValues): 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
* Function returns the export type - This can be extended to support different file exports.
- 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
$inventoryEntries['inv_' . $columnName] = $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
foreach ($this->fields as $dbKey => $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $response;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header("content-disposition: attachment; filename=\"{$this->getFileName()}\"");
- 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 getExportContentType(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('source_field_name', $referenceField);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get file headers.
- 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 getFieldsForQuery(): 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
public function getAllModuleFieldsAsHeaders(): array
- 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
* Function that generates Export Query object.
- 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 ($field->getCustomColumn() as $customColumnName => $dbType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header("content-type: {$this->getExportContentType()}; charset=UTF-8");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $inventoryRow[$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
/**
- 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 ($this->fields as $dbKey => $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = $fieldModel->get('source_field_name') . $fieldModel->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$idKey = $name . $idKey;
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
$response[$fieldModel->getFullName()] = $fieldModel->getUITypeModel()->getValueToExport($recordValues[$dbKey], $recordValues[$idKey] ?? 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get display value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('sharedOwner' === $fieldModel->getFieldDataType() && $recordId) {
- 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
$idKey = $name . $idKey;
- 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 record data in export format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $rowData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDisplayValue(\Vtiger_Field_Model $fieldModel, $value, int $recordId, array $rowData, $length = 65000)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnValue = $fieldModel->getDisplayValue($value, $recordId, null, true, $length);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 167 characters Open
return \App\Utils::sanitizeSpecialChars(\App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName))) . ".{$this->fileExtension}";
- 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
$name = $fieldModel->get('source_field_name') . $fieldModel->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $response;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $recordValues
- 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
$returnValue = \App\Purifier::decodeHtml($returnValue);
- 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 (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function sanitizeInventoryValues(array $inventoryRow, array $inventoryFields): array
- 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
$value = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$idKey = 'id';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Field_Model $fieldModel
- 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 $returnValue && 'text' === $fieldModel->getFieldDataType() ? strip_tags($returnValue) : $returnValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Fields\File::getMimeContentType($this->getFileName());
- 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
$valueNewData = [];
- 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
$dbKey = $name . $fieldModel->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response[$fieldModel->getFullName()] = $this->getDisplayValue($fieldModel, $recordValues[$dbKey], $recordValues[$idKey] ?? 0, $recordValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function sendHttpHeader(): void
- 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 (\in_array($field->getType(), ['Name', 'Reference'])) {
- 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
$valueParam = $inventoryRow[$customColumnName];
- 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
$valueNewData[$currencyName] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$valueParam = \App\Json::encode($valueNewData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $recordValues
- 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 void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($inventoryFields as $columnName => $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$field = $inventoryFields['currency'];
- 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
$response = [];
- 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
* Send HTTP Header.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('pragma: public');
- 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 = trim($value);
- 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
$idKey = 'id';
- 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
$inventoryEntries = [];
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $length
- 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
* @param string $moduleName
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $inventoryEntries;
- 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 getDataInExportFormat(array $recordValues): 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('currencyparam' === $customColumnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($valueData)) {
- 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 array
- 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
$dbKey = $name . $fieldModel->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $recordId
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
public function getDisplayValue(\Vtiger_Field_Model $fieldModel, $value, int $recordId, array $rowData, $length = 65000)
- 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
} 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
}
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
$response[$fieldModel->getFullName()] = $this->getDisplayValue($fieldModel, $recordValues[$dbKey], $recordValues[$idKey] ?? 0, $recordValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = [];
- 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_string($returnValue)) {
- 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('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
*
- 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
public function getFileName(): 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
return \App\Utils::sanitizeSpecialChars(\App\Purifier::decodeHtml(\App\Language::translate($this->moduleName, $this->moduleName))) . ".{$this->fileExtension}";
- 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
$currencyName = \App\Fields\Currency::getById($currencyId)['currency_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get data from record in display format.
- 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
$response[$fieldModel->getFullName()] = $fieldModel->getUITypeModel()->getValueToExport($recordValues[$dbKey], $recordValues[$idKey] ?? 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = implode(',', \App\Fields\SharedOwner::getById($recordId));
- 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('expires: Mon, 31 Dec 2000 00:00:00 GMT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks