Function loadData
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function loadData(): void
{
if (empty($this->data)) {
return;
}
- 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 loadData
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadData(): void
{
if (empty($this->data)) {
return;
}
Function getFields
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getFields(): array
{
$fieldsModel = [];
foreach ($this->fields as $fieldName => $data) {
if (isset($data['picklistValuesFunction'])) {
- 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 Base has 16 fields. Consider redesigning Base to keep the number of fields under 15. Open
class Base
{
/** @var string Module name. */
public $moduleName;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The method loadData() has an NPath complexity of 6216. The configured NPath complexity threshold is 200. Open
public function loadData(): void
{
if (empty($this->data)) {
return;
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method loadData() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10. Open
public function loadData(): void
{
if (empty($this->data)) {
return;
}
- 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
Avoid using undefined variables such as '$dataCounter' which will lead to PHP notices. Open
$this->response['dataCounter'] = $dataCounter;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$dataCounter' which will lead to PHP notices. Open
$dataCounter[$key] = 0;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$dataCounter' which will lead to PHP notices. Open
++$dataCounter[$key];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '282', column '22'). Open
if ($params = (new \App\Db\Query())->select(['params'])->from('vtiger_links')->where(['linktype' => 'EDIT_VIEW_RECORD_COLLECTOR', 'linkurl' => static::class])->scalar()) {
- 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 '80', column '18'). Open
$config = (new \ReflectionClass($class))->getStaticProperties();
- 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 '184', column '13'). Open
throw new \Api\Core\Exception('no search function');
- 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 using static access to class '\App\Log' in method 'getFields'. Open
\App\Log::error($th->__toString(), 'RecordCollectors');
- 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 'loadData'. Open
$skip[$fieldName]['label'] = \App\Language::translate($fieldsModel[$fieldName]->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\Language' in method 'loadData'. Open
$fieldsData[$fieldName]['label'] = \App\Language::translate($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 '\Vtiger_Record_Model' in method 'loadData'. Open
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId, $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 '197', column '7'). Open
public function loadData(): void
{
if (empty($this->data)) {
return;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method loadData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldsModel = \Vtiger_Module_Model::getInstance($this->moduleName)->getFields();
}
- 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 assigning values to variables in if clauses and the like (line '282', column '7'). Open
protected function getParams(): array
{
if ($params = (new \App\Db\Query())->select(['params'])->from('vtiger_links')->where(['linktype' => 'EDIT_VIEW_RECORD_COLLECTOR', 'linkurl' => static::class])->scalar()) {
return \App\Json::decode($params, true);
}
- 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 'getFields'. Open
$data['picklistValues'][$picklistKey] = \App\Language::translate($value, $picklistModule);
- 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_Field_Model' in method 'getFields'. Open
$fieldModel = \Vtiger_Field_Model::init($this->moduleName, $data, $fieldName);
- 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 'getParams'. Open
return \App\Json::decode($params, true);
- 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\YetiForce\Shop' in method 'isAvailable'. Open
return !$this->paid || \App\YetiForce\Shop::check($this->addOnName);
- 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 loadData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$skip[$fieldName]['label'] = $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
syntax error, unexpected 'bool' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
protected bool $paid = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!class_exists($class)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->{$key} = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->modulesFieldsMap[$this->moduleName][$fieldName]) && $this->request->has($this->modulesFieldsMap[$this->moduleName][$fieldName])) {
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
if (isset($this->modulesFieldsMap[$this->moduleName][$fieldName]) && $this->request->has($this->modulesFieldsMap[$this->moduleName][$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
/**
- Exclude checks
Spaces must 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 search(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $label;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Record collector name. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Fields mapping for loading record data. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$config = (new \ReflectionClass($class))->getStaticProperties();
- Exclude checks
Spaces must 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 getName(): 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
$data['picklistValues'] = $this->{$data['picklistValuesFunction']}($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 the module name.
- 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
/** @var string Search results display type. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $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
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Vtiger_Field_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
public $docUrl;
- 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
protected $request;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Requires subscription. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (isset($data['picklistValues']) && false !== $data['picklistModule']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Module name. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Additional description, visible in the modal window. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected bool $paid = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($config['allowedModules'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error($th->__toString(), 'RecordCollectors');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFieldsModule(string $moduleName): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check whether it is active.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isAvailable(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string The name of Add-on. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->allowedModules = $config['allowedModules'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($config as $key => $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
if (isset($data['picklistValuesFunction'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($data['picklistValues'] as $picklistKey => $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
* @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
/** var array List of fields for the modal search window. */
- Exclude checks
Spaces must 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->request = $request;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uitypeModel->validate($value, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Icon. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $icon;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get record collector name.
- 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
$uitypeModel = $fieldModel->getUITypeModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->modulesFieldsMap[$moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isActive(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if product is available.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \App\Request Request instance. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $modulesFieldsMap = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$class = '\\Config\\Components\\RecordCollectors\\' . $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
$fieldsModel = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = \Vtiger_Field_Model::init($this->moduleName, $data, $fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $this->request->getByType($this->modulesFieldsMap[$this->moduleName][$fieldName], 'Text');
- Exclude checks
Spaces must 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->paid || \App\YetiForce\Shop::check($this->addOnName);
- 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 $allowedModules;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Label. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Data from record collector source. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $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
return;
- Exclude checks
Spaces must 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
}
- Exclude checks
Spaces must 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 bool
- Exclude checks
Spaces must 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 $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Configuration field list. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = basename(str_replace('\\', '/', static::class));
- Exclude checks
Spaces must 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 setRequest(\App\Request $request): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->fields as $fieldName => $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('fieldvalue', $uitypeModel->getDBValue($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 bool
- Exclude checks
Spaces must 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
* Get fields for the modal search window.
- Exclude checks
Spaces must 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 \in_array($this->moduleName, $this->allowedModules) && $this->isAvailable();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Url to Documentation API */
- Exclude checks
Spaces must 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
} catch (\Throwable $th) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldsModel;
- Exclude checks
Spaces must 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 $displayType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Response data. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFields(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId, $this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsModel = $recordModel->getModule()->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsModel = \Vtiger_Module_Model::getInstance($this->moduleName)->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows as $key => &$row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->formFieldsToRecordMap[$this->moduleName] as $apiKey => $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = trim($row[$apiKey]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['additional'] = $additional;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get fields labels for the module 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
/** @var string[] Allowed modules. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->name = $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
$picklistModule = $data['picklistModule'] ?? $this->moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['picklistValues'][$picklistKey] = \App\Language::translate($value, $picklistModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsModel[$fieldName] = $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
* Search data function.
- Exclude checks
Spaces must 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($fieldsModel[$fieldName]) && empty($skip[$fieldName]['label'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$skip[$fieldName]['label'] = \App\Language::translate($fieldsModel[$fieldName]->getFieldLabel(), $this->moduleName);
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
$skip[$fieldName]['label'] = \App\Language::translate($fieldsModel[$fieldName]->getFieldLabel(), $this->moduleName);
- 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
$skip[$fieldName]['label'] = $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
unset($row[$apiKey]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' === $value && isset($fieldsData[$fieldName]['data'][$key])) {
- Exclude checks
Spaces must 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 $description;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $settingsFields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $addOnName = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($config['allowedModules']);
- Exclude checks
Spaces must 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 request.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must 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->response['skip'] = $skip;
- Exclude checks
Spaces must 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 loadData(): void
- 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
$rows = isset($this->data[0]) ? $this->data : [$this->data];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($row)) {
- 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
}
- Exclude checks
Spaces must 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->response['keys'] = array_keys($rows);
- 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
'display' => $fieldModel->getDisplayValue($value, false, false, false, 40),
- Exclude checks
Spaces must 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 \App\Json::decode($params, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$additional = $fieldsData = $skip = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsData[$fieldName]['data'][$key] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->formFieldsToRecordMap[$moduleName] as $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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recordId = $this->request->getInteger('record')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsModels = \Vtiger_Module_Model::getInstance($moduleName)->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
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($params = (new \App\Db\Query())->select(['params'])->from('vtiger_links')->where(['linktype' => 'EDIT_VIEW_RECORD_COLLECTOR', 'linkurl' => static::class])->scalar()) {
- Exclude checks
Spaces must 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 ($value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($row as $name => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$additional[$name][$key] = $value;
- 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
$labels[$fieldName] = $fieldsModels[$fieldName]->getFullLabelTranslation();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \Api\Core\Exception('no search function');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load 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
$dataCounter[$key] = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($row[$apiKey]) && '' !== $row[$apiKey] && null !== $row[$apiKey]) {
- 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
'edit' => $fieldModel->getEditViewDisplayValue($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
public function getFieldsLabelsByModule(string $moduleName): array
- 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 (empty($this->data)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$skip[$fieldName]['data'][$key] = $row[$apiKey];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['fields'] = $fieldsData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['dataCounter'] = $dataCounter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['recordModel'] = $recordModel;
- Exclude checks
Spaces must 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($row[$apiKey])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsData[$fieldName]['label'] = \App\Language::translate($fieldModel->getFieldLabel(), $this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'raw' => $value,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labels = [];
- Exclude checks
Spaces must 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 [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$dataCounter[$key];
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$fieldsData[$fieldName]['label'] = \App\Language::translate($fieldModel->getFieldLabel(), $this->moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($fieldsModels[$fieldName]) && $fieldsModels[$fieldName]->isActiveField()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get params of collector.
- Exclude checks
Spaces must 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
unset($row[$apiKey]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' !== $value && null !== $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
protected function getParams(): array
- Exclude checks
Line exceeds 120 characters; contains 179 characters Open
if ($params = (new \App\Db\Query())->select(['params'])->from('vtiger_links')->where(['linktype' => 'EDIT_VIEW_RECORD_COLLECTOR', 'linkurl' => static::class])->scalar()) {
- 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
if (empty($fieldsModel[$fieldName]) || !$fieldsModel[$fieldName]->isActiveField()) {
- 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
$fieldModel = $fieldsModel[$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
}
- Exclude checks
Spaces must 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 $labels;
- Exclude checks