Function computeLabels
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public static function computeLabels($moduleName, $ids, $search = false): ?array
{
if (empty($moduleName) || empty($ids)) {
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
The class Record has an overall complexity of 78 which is very high. The configured complexity threshold is 50. Open
class Record
{
/**
* Get label.
*
- Exclude checks
File Record.php
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Record basic file.
*
* @package App
Method computeLabels
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function computeLabels($moduleName, $ids, $search = false): ?array
{
if (empty($moduleName) || empty($ids)) {
return [];
}
Function updateLabelOnSave
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function updateLabelOnSave(\Vtiger_Record_Model $recordModel): void
{
$label = '';
$metaInfo = \App\Module::getEntityInfo($recordModel->getModuleName());
$dbCommand = Db::getInstance()->createCommand();
- 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 updateLabelOnSave
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function updateLabelOnSave(\Vtiger_Record_Model $recordModel): void
{
$label = '';
$metaInfo = \App\Module::getEntityInfo($recordModel->getModuleName());
$dbCommand = Db::getInstance()->createCommand();
Function updateLabel
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function updateLabel(string $moduleName, int $id): void
{
$dbCommand = \App\Db::getInstance()->createCommand();
$labelTableName = \App\RecordSearch::LABEL_TABLE_NAME;
$searchTableName = \App\RecordSearch::SEARCH_TABLE_NAME;
- 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 getLabel
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function getLabel($mixedId, bool $raw = false)
{
$multiMode = \is_array($mixedId);
$ids = array_filter($multiMode ? array_unique($mixedId) : [$mixedId]);
$result = $missing = [];
- 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 getLabel
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getLabel($mixedId, bool $raw = false)
{
$multiMode = \is_array($mixedId);
$ids = array_filter($multiMode ? array_unique($mixedId) : [$mixedId]);
$result = $missing = [];
Method getHtmlLink
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
{
$state = self::getState($id);
if (null === $state) {
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
Function getParentRecord
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function getParentRecord($recordId, $moduleName = false): ?int
{
if (Cache::has(__METHOD__, $recordId)) {
return Cache::get(__METHOD__, $recordId);
}
- 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 getHtmlLink
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
{
$state = self::getState($id);
if (null === $state) {
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- 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 getHtmlLink() has an NPath complexity of 384. The configured NPath complexity threshold is 200. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
{
$state = self::getState($id);
if (null === $state) {
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- 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 computeLabels() has an NPath complexity of 1872. The configured NPath complexity threshold is 200. Open
public static function computeLabels($moduleName, $ids, $search = false): ?array
{
if (empty($moduleName) || empty($ids)) {
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 getLabel() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function getLabel($mixedId, bool $raw = false)
{
$multiMode = \is_array($mixedId);
$ids = array_filter($multiMode ? array_unique($mixedId) : [$mixedId]);
$result = $missing = [];
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method computeLabels() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
public static function computeLabels($moduleName, $ids, $search = false): ?array
{
if (empty($moduleName) || empty($ids)) {
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
The method getHtmlLink() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
{
$state = self::getState($id);
if (null === $state) {
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method updateLabelOnSave() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function updateLabelOnSave(\Vtiger_Record_Model $recordModel): void
{
$label = '';
$metaInfo = \App\Module::getEntityInfo($recordModel->getModuleName());
$dbCommand = Db::getInstance()->createCommand();
- 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
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed. Open
public static function updateLabelOnSave(\Vtiger_Record_Model $recordModel): void
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 34 to the 15 allowed. Open
public static function computeLabels($moduleName, $ids, $search = false): ?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 Record has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13. Open
class Record
{
/**
* Get label.
*
- 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 '43', column '18'). Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method computeLabels has a boolean flag argument $search, which is a certain sign of a Single Responsibility Principle violation. Open
public static function computeLabels($moduleName, $ids, $search = false): ?array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '124', column '17'). Open
$query = new \App\Db\Query();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getCrmIdByLabel has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getCrmIdByLabel($moduleName, $label, $userId = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getLabel has a boolean flag argument $raw, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getLabel($mixedId, bool $raw = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '78', column '17'). Open
$query = (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '194', column '13'). Open
if ((new \App\Db\Query())->from($labelTableName)->where(['crmid' => $id])->exists()) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method isExists has a boolean flag argument $moduleName, which is a certain sign of a Single Responsibility Principle violation. Open
public static function isExists($recordId, $moduleName = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '347', column '23'). Open
$parentId = (new \App\Db\Query())->select(["{$field['tablename']}.{$field['columnname']}"])
- 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 '201', column '14'). Open
if ((new \App\Db\Query())->from($searchTableName)->where(['crmid' => $id])->exists()) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '375', column '14'). Open
$id = (new \App\Db\Query())->select(['vtiger_crmentity.crmid'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getParentRecord has a boolean flag argument $moduleName, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getParentRecord($recordId, $moduleName = false): ?int
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getHtmlLink has a boolean flag argument $fullUrl, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getLabel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result[$id] = Cache::get('recordLabel', $id);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'App\Cache' in method 'getLabel'. Open
$result[$id] = Cache::get('recordLabel', $id);
- 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\RecordSearch' in method 'updateLabel'. 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\Cache' in method 'getLabel'. Open
if (!Cache::has('recordLabel', $id)) {
- 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\Cache' in method 'getCrmIdByLabel'. Open
if (\App\Cache::staticHas(__METHOD__, $key)) {
- 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\Completions' in method 'getLabel'. Open
$label = \App\Utils\Completions::decodeEmoji($row['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\Cache' in method 'getLabel'. Open
Cache::save('recordLabel', $row['crmid'], $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
The method computeLabels uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query = \App\Cache::staticGet($cacheName, $moduleName);
$columnsName = $metaInfo['fieldnameArr'];
$columnsSearch = $metaInfo['searchcolumnArr'];
$idColumn = $metaInfo['entityidfield'];
- 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\TextUtils' in method 'computeLabels'. Open
$searchLabel = TextUtils::textTruncate(trim(implode($separator, $labelName)), 250, false);
- 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\Cache' in method 'getLabel'. Open
Cache::save('recordLabel', $id, $computeLabel);
- 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\Module' in method 'computeLabels'. Open
$metaInfo = \App\Module::getEntityInfo($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\Cache' in method 'computeLabels'. Open
$query = \App\Cache::staticGet($cacheName, $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 'computeLabels'. Open
$moduleModel = \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\RecordSearch' in method 'updateLabelOnSave'. 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\Cache' in method 'computeLabels'. Open
\App\Cache::staticSave($cacheName, $moduleName, clone $query);
- 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\TextUtils' in method 'computeLabels'. Open
$label = TextUtils::textTruncate(trim(implode($separator, $labelName)), 250, false);
- 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 computeLabels uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$entityDisplay[$recordId] = $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\Cache' in method 'computeLabels'. Open
if (!\App\Cache::staticHas($cacheName, $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\Field' in method 'computeLabels'. Open
$moduleInfoExtend = \App\Field::getModuleFieldInfos($moduleName, 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 '\vtlib\Functions' in method 'getLabel'. Open
$metaInfo = Functions::getCRMRecordMetadata($id);
- 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\Cache' in method 'getCrmIdByLabel'. Open
return \App\Cache::staticGet(__METHOD__, $key);
- 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 updateLabel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dbCommand->insert($labelTableName, ['crmid' => $id, 'label' => $label])->execute();
}
- 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 '\CRMEntity' in method 'getParentRecord'. Open
$entity = \CRMEntity::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\Cache' in method 'getCrmIdByLabel'. Open
\App\Cache::staticSave(__METHOD__, $key, $crmId);
- 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 updateLabel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$label = $metaInfo[$id]['name'];
if ((new \App\Db\Query())->from($labelTableName)->where(['crmid' => $id])->exists()) {
$dbCommand->update($labelTableName, ['label' => $label], ['crmid' => $id])->execute();
} else {
- 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 updateLabelOnSave uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dbCommand->update('u_#__crmentity_label', ['label' => $label], ['crmid' => $recordModel->getId()])->execute();
}
- 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\TextUtils' in method 'updateLabelOnSave'. Open
$search = TextUtils::textTruncate(trim(implode($separator, $labelSearch)), 250, false) ?: '';
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\vtlib\Functions' in method 'isExists'. Open
$recordMetaData = Functions::getCRMRecordMetadata($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
Avoid using static access to class '\Vtiger_Inventory_Model' in method 'getCurrencyIdFromInventory'. Open
$invData = \Vtiger_Inventory_Model::getInventoryDataById($recordId, $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\Cache' in method 'getParentRecord'. Open
return Cache::get(__METHOD__, $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
Avoid using static access to class 'App\Cache' in method 'getIdByRecordNumber'. Open
if (Cache::staticHas(__METHOD__, $recordNumber)) {
- 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\Currency' in method 'getCurrencyIdFromInventory'. 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\Cache' in method 'updateLabelOnSave'. Open
Cache::save('recordLabel', $recordModel->getId(), $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 'getHtmlLink'. Open
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- 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 updateLabelOnSave uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dbCommand->update('u_#__crmentity_search_label', ['searchlabel' => $search], ['crmid' => $recordModel->getId()])->execute();
}
- 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 'getHtmlLink'. Open
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- 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\TextUtils' in method 'updateLabelOnSave'. Open
$label = TextUtils::textTruncate(trim(implode($separator, $labelName)), 250, false) ?: '';
- 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 '342', column '7'). Open
public static function getParentRecord($recordId, $moduleName = false): ?int
{
if (Cache::has(__METHOD__, $recordId)) {
return Cache::get(__METHOD__, $recordId);
}
- 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\Cache' in method 'getIdByRecordNumber'. Open
return Cache::staticGet(__METHOD__, $recordNumber);
- 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 'updateLabelOnSave'. Open
$recordModel->label = \App\Purifier::encodeHtml($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\ModuleHierarchy' in method 'getParentRecord'. Open
if ($parentModules = ModuleHierarchy::getModulesMap1M($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\RecordNumber' in method 'getIdByRecordNumber'. Open
$field = Fields\RecordNumber::getSequenceNumberField(Module::getModuleId($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\Privilege' in method 'getHtmlLink'. Open
if ($id && !Privilege::isPermitted($moduleName, 'DetailView', $id)) {
- 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 updateLabel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dbCommand->insert($searchTableName, ['crmid' => $id, 'searchlabel' => $label, 'tabid' => \App\Module::getModuleId($moduleName)])->execute();
}
- 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 '\vtlib\Functions' in method 'getType'. Open
$metadata = Functions::getCRMRecordMetadata($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
Avoid using static access to class '\CRMEntity' in method 'getIdByRecordNumber'. Open
$entity = \CRMEntity::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\TextUtils' in method 'getHtmlLink'. Open
$label = TextUtils::textTruncate($label, $length);
- 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\Cache' in method 'getParentRecord'. Open
Cache::save(__METHOD__, $recordId, $parentId);
- 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 'getHtmlLink'. Open
$moduleModel = \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 '\vtlib\Functions' in method 'getState'. Open
$metadata = Functions::getCRMRecordMetadata($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
Avoid using static access to class 'App\Field' in method 'getParentRecord'. Open
if ($field = Field::getRelatedFieldForModule($moduleName, $parentModule)) {
- 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\Module' in method 'getIdByRecordNumber'. Open
$field = Fields\RecordNumber::getSequenceNumberField(Module::getModuleId($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\Cache' in method 'getParentRecord'. Open
if (Cache::has(__METHOD__, $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
Avoid using static access to class 'App\Cache' in method 'getIdByRecordNumber'. Open
Cache::staticSave(__METHOD__, $recordNumber, $id);
- 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\Module' in method 'updateLabel'. Open
$dbCommand->insert($searchTableName, ['crmid' => $id, 'searchlabel' => $label, 'tabid' => \App\Module::getModuleId($moduleName)])->execute();
- 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 updateLabelOnSave uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$separator = $metaInfo['separator'] ?? ' ';
$labelName = [];
foreach ($metaInfo['fieldnameArr'] as $columnName) {
$fieldModel = $recordModel->getModule()->getFieldByColumn($columnName);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'App\Cache' in method 'updateLabel'. Open
Cache::save('recordLabel', $id, $metaInfo[$id]['name']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'updateLabelOnSave'. Open
$metaInfo = \App\Module::getEntityInfo($recordModel->getModuleName());
- 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 '344', column '9'). Open
public static function getParentRecord($recordId, $moduleName = false): ?int
{
if (Cache::has(__METHOD__, $recordId)) {
return Cache::get(__METHOD__, $recordId);
}
- 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
Define a constant instead of duplicating this literal "vtiger_crmentity" 3 times. Open
->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid')
- 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 "searchcolumnArr" 5 times. Open
if (!$metaInfo || (empty($metaInfo['fieldnameArr']) && empty($metaInfo['searchcolumnArr']))) {
- 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 "searchlabel" 4 times. Open
$dbCommand->update($searchTableName, ['searchlabel' => $label], ['crmid' => $id])->execute();
- 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 "recordLabel" 6 times. Open
if (!Cache::has('recordLabel', $id)) {
- 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 "setype" 3 times. Open
$computeLabel = static::computeLabels($metaInfo['setype'] ?? '', $id)[$id] ?? '';
- 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 "u_#__crmentity_search_label" 3 times. Open
$dbCommand->delete('u_#__crmentity_search_label', ['crmid' => $recordModel->getId()])->execute();
- 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 "u_#__crmentity_label" 4 times. Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- 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 "crmid" 18 times. Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- 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 "label" 6 times. Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- 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 "tablename" 11 times. Open
$table = $metaInfo['tablename'];
- 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 "fieldnameArr" 5 times. Open
if (!$metaInfo || (empty($metaInfo['fieldnameArr']) && empty($metaInfo['searchcolumnArr']))) {
- 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.
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
if ((new \App\Db\Query())->from($searchTableName)->where(['crmid' => $id])->exists()) {
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$id = (new \App\Db\Query())->select(['vtiger_crmentity.crmid'])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- Exclude checks
Call to method read
from undeclared class \yii\db\DataReader
Open
while ($row = $dataReader->read()) {
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = Db::getInstance()->createCommand();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save('recordLabel', $recordModel->getId(), $label);
- Exclude checks
Argument 1 (moduleName)
is ?string|?true
but \App\Field::getRelatedFieldForModule()
takes bool|false|string
defined at /code/app/Field.php:232
Open
if ($field = Field::getRelatedFieldForModule($moduleName, $parentModule)) {
- Exclude checks
Call to undeclared method \App\Db\Query::leftJoin
Open
$query->leftJoin($otherTable, "$table.$focusTables[$table] = $otherTable.$focusTables[$otherTable]");
- Exclude checks
Argument 1 (moduleName)
is ?string
but \App\Privilege::isPermitted()
takes string
defined at /code/app/Privilege.php:48
Open
if ($id && !Privilege::isPermitted($moduleName, 'DetailView', $id)) {
- Exclude checks
Call to method decodeEmoji
from undeclared class \App\Utils\Completions
Open
$label = \App\Utils\Completions::decodeEmoji($row['label']);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (Cache::has(__METHOD__, $recordId)) {
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save(__METHOD__, $recordId, $parentId);
- Exclude checks
Argument 1 (mixed)
is ?string
but \Vtiger_Module_Model::getInstance()
takes int|string
defined at /code/modules/Vtiger/models/Module.php:197
Open
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$parentId = (new \App\Db\Query())->select(["{$field['tablename']}.{$field['columnname']}"])
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'name',
but expected the index to be of type int
Open
$label = $metaInfo[$id]['name'];
- Exclude checks
Default value for int
$userId
can't be false
Open
public static function getCrmIdByLabel($moduleName, $label, $userId = false)
- Exclude checks
Call to undeclared method \App\Db\Query::where
Open
$query->where([$idColumn => $ids]);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save('recordLabel', $id, $metaInfo[$id]['name']);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select($paramsCol)->from($table);
- Exclude checks
Argument 1 (module)
is ?string|?true
but \CRMEntity::getInstance()
takes string
defined at /code/include/CRMEntity.php:61
Open
$entity = \CRMEntity::getInstance($moduleName);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
if ((new \App\Db\Query())->from($labelTableName)->where(['crmid' => $id])->exists()) {
- Exclude checks
Returning type ?'Active'|?'Archived'|?'Trash'
but getState()
is declared to return string
Open
return $state;
- Exclude checks
Call to method getSequenceNumberField
from undeclared class \App\Fields\RecordNumber
(Did you mean class \Tests\Base\RecordNumber) Open
$field = Fields\RecordNumber::getSequenceNumberField(Module::getModuleId($moduleName));
- Exclude checks
Reference to static property site_URL
from undeclared class \Config\Main
Open
$url = \Config\Main::$site_URL . $url;
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'search',
but expected the index to be of type int
Open
$label = $metaInfo[$id]['search'];
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'name',
but expected the index to be of type int
Open
Cache::save('recordLabel', $id, $metaInfo[$id]['name']);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
return Cache::get(__METHOD__, $recordId);
- Exclude checks
Default value for string
$moduleName
can't be false
Open
public static function isExists($recordId, $moduleName = false)
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
public static function updateLabel(string $moduleName, int $id): void
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = (new \App\Db\Query())->select(['vtiger_crmentity.crmid'])
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must 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
$multiMode = \is_array($mixedId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $mixedId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $raw
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get label.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return mixed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ids = array_filter($multiMode ? array_unique($mixedId) : [$mixedId]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLabel($mixedId, bool $raw = 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $missing = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($missing)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result[$id] = $computeLabel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['cl.crmid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$otherTable = $moduleInfoExtend[$column]['tablename'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($columnsName as $columnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entityDisplay[$recordId] = ['name' => $label, 'search' => $searchLabel];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must 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 getCrmIdByLabel($moduleName, $label, $userId = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function gets labels for record 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Cache::staticGet(__METHOD__, $key);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('u_#__crmentity_label cl')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $search
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$metaInfo = \App\Module::getEntityInfo($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\Cache::staticHas($cacheName, $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
$paramsCol['id'] = $idColumn;
- 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
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$computeLabel = static::computeLabels($metaInfo['setype'] ?? '', $id)[$id] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ids = [$ids];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnsName = $metaInfo['fieldnameArr'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticSave($cacheName, $moduleName, clone $query);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $entityDisplay;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$table = $metaInfo['tablename'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = new \App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = \App\Cache::staticGet($cacheName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelName = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $moduleModel->getFieldByColumn($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
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['cl.label' => $label]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[]|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
$cacheName = 'computeLabelsQuery';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$idColumn = $metaInfo['entityidfield'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$separator = $metaInfo['separator'] ?? ' ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result[$id] = Cache::get('recordLabel', $id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must 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
$moduleInfoExtend = \App\Field::getModuleFieldInfos($moduleName, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (array_filter($columns) as $column) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$missing[$id] = $id;
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- Exclude checks
Spaces must 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 ($userId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entityDisplay = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leftJoinTables = $paramsCol = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\array_key_exists($column, $moduleInfoExtend)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leftJoinTables[] = $otherTable;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select($paramsCol)->from($table);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchLabel = TextUtils::textTruncate(trim(implode($separator, $labelName)), 250, 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->select(['crmid', 'label'])->from('u_#__crmentity_label')->where(['crmid' => $missing]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$metaInfo = Functions::getCRMRecordMetadata($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$raw && $result) {
- 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
if (\App\Cache::staticHas(__METHOD__, $key)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_crmentity.setype' => $moduleName])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($otherTable !== $table && !\in_array($otherTable, $leftJoinTables)) {
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$query->leftJoin($otherTable, "$table.$focusTables[$table] = $otherTable.$focusTables[$otherTable]");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ids = array_unique($ids);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($search) {
- Exclude checks
Spaces must 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 $label
- 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
$idColumn = $table . '.' . $metaInfo['entityidfield'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnsSearch = $metaInfo['searchcolumnArr'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnsName = $metaInfo['fieldnameArr'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnsSearch = $metaInfo['searchcolumnArr'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelName[] = $fieldModel ? $fieldModel->getDisplayValue($row[$columnName], $recordId, false, 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
Cache::save('recordLabel', $row['crmid'], $label);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (array_diff_key($missing, $result) as $id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function searches for record ID with given label.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$key = $moduleName . $label . '_' . $userId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $crmId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array|int $ids
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->leftJoin($otherTable, "$table.$focusTables[$table] = $otherTable.$focusTables[$otherTable]");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordId = $row['id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelName = [];
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['like', 'vtiger_crmentity.users', ",$userId,"]);
- Exclude checks
Spaces must 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 (!$metaInfo || (empty($metaInfo['fieldnameArr']) && empty($metaInfo['searchcolumnArr']))) {
- Exclude checks
Spaces must 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 ($columnsSearch as $columnName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = array_map('\App\Purifier::encodeHtml', $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
$query = (new \App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticSave(__METHOD__, $key, $crmId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($moduleName) || empty($ids)) {
- 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
if (!\is_array($ids)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$focus = $moduleModel->getEntityInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $moduleModel->getFieldByColumn($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
$label = TextUtils::textTruncate(trim(implode($separator, $labelName)), 250, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entityDisplay[$recordId] = $label;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update record 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
$result[$row['crmid']] = $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
}
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$labelName[] = $fieldModel ? $fieldModel->getDisplayValue($row[$columnName], $recordId, false, true) : '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelName[] = $fieldModel ? $fieldModel->getDisplayValue($row[$columnName], $recordId, false, true) : '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function updateLabel(string $moduleName, int $id): 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
* @param int $userId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmId = $query->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columns = array_unique(array_merge($columnsName, $columnsSearch));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$paramsCol[] = $otherTable . '.' . $column;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$focusTables = $focus->tab_name_index;
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$labelName[] = $fieldModel ? $fieldModel->getDisplayValue($row[$columnName], $recordId, false, true) : '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($ids as $id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!Cache::has('recordLabel', $id)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = \App\Utils\Completions::decodeEmoji($row['label']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('recordLabel', $id, $computeLabel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $multiMode ? $result : reset($result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function computeLabels($moduleName, $ids, $search = false): ?array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where([$idColumn => $ids]);
- Exclude checks
Spaces must 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 $id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$metaInfo = static::computeLabels($moduleName, $id, 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
$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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getParentRecord($recordId, $moduleName = false): ?int
- Exclude checks
Spaces must 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
}
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$dbCommand->update('u_#__crmentity_label', ['label' => $label], ['crmid' => $recordModel->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('recordLabel', $recordModel->getId(), $label);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getState($recordId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->insert($labelTableName, ['crmid' => $id, 'label' => $label])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($metaInfo['fieldnameArr'] as $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
$fieldModel = $recordModel->getModule()->getFieldByColumn($columnName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelSearch[] = $fieldModel->getDisplayValue($recordModel->get($fieldModel->getName()), $recordModel->getId(), $recordModel, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $metadata ? $metadata['setype'] : null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get the currency ID for the inventory record.
- 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
if (!$metaInfo) {
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
$labelName[] = $fieldModel->getDisplayValue($recordModel->get($fieldModel->getName()), $recordModel->getId(), $recordModel, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recordModel->isNew()) {
- Exclude checks
Spaces must 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 getType($recordId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$metadata = Functions::getCRMRecordMetadata($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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update record label on save.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $recordModel->getModule()->getFieldByColumn($columnName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$search = TextUtils::textTruncate(trim(implode($separator, $labelSearch)), 250, false) ?: '';
- 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
* @param int $recordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state = 'Trash';
- Exclude checks
Spaces must 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 ((new \App\Db\Query())->from($searchTableName)->where(['crmid' => $id])->exists()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->insert($searchTableName, ['crmid' => $id, 'searchlabel' => $label, 'tabid' => \App\Module::getModuleId($moduleName)])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->delete('u_#__crmentity_search_label', ['crmid' => $recordModel->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->update('u_#__crmentity_label', ['label' => $label], ['crmid' => $recordModel->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$metaInfo || (empty($metaInfo['fieldnameArr']) && empty($metaInfo['searchcolumnArr']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelSearch = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->delete('u_#__crmentity_label', ['crmid' => $recordModel->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(\App\RecordSearch::getSearchableModules()[$recordModel->getModuleName()])) {
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
$dbCommand->update('u_#__crmentity_search_label', ['searchlabel' => $search], ['crmid' => $recordModel->getId()])->execute();
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
$labelSearch[] = $fieldModel->getDisplayValue($recordModel->get($fieldModel->getName()), $recordModel->getId(), $recordModel, 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
*
- Exclude checks
Spaces must 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 current($invData)['currency'] ?? Fields\Currency::getDefault()['id'] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state = 'Archived';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->delete($searchTableName, ['crmid' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->update($searchTableName, ['searchlabel' => $label], ['crmid' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordMetaData = Functions::getCRMRecordMetadata($recordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $recordId
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must 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 $recordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int|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
$parentId = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', "{$field['tablename']}.{$index} = vtiger_crmentity.crmid")
- Exclude checks
Spaces must 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
$field = Fields\RecordNumber::getSequenceNumberField(Module::getModuleId($moduleName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$id = (new \App\Db\Query())->select(['vtiger_crmentity.crmid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', "{$field['tablename']}.{$index} = vtiger_crmentity.crmid")
- Exclude checks
Spaces must 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 bool $fullUrl
- Exclude checks
Spaces must 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 '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = TextUtils::textTruncate($label, $length);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(\App\RecordSearch::getSearchableModules()[$moduleName])) {
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
$dbCommand->insert($searchTableName, ['crmid' => $id, 'searchlabel' => $label, 'tabid' => \App\Module::getModuleId($moduleName)])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save('recordLabel', $id, $metaInfo[$id]['name']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->update('u_#__crmentity_search_label', ['searchlabel' => $search], ['crmid' => $recordModel->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getCurrencyIdFromInventory(int $recordId, string $moduleName): ?int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 0:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool|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
* Get record link and 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
return $deleted ? "<s>{$label}</s>" : $label;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = \Config\Main::$site_URL . $url;
- Exclude checks
Spaces must 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
Line exceeds 120 characters; contains 190 characters Open
$dbCommand->insert('u_#__crmentity_search_label', ['crmid' => $recordModel->getId(), 'searchlabel' => $search, 'tabid' => $recordModel->getModule()->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function checks if record exists.
- 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
public static function isExists($recordId, $moduleName = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (isset($recordMetaData) && 1 !== $recordMetaData['deleted'] && ($moduleName ? $recordMetaData['setype'] === $moduleName : true)) ? true : false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$metadata = Functions::getCRMRecordMetadata($recordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 1:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state = 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
Cache::save(__METHOD__, $recordId, $parentId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get record id by record number .
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = self::getType($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $deleted ? "<s>{$label}</s>" : $label;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$metaInfo = \App\Module::getEntityInfo($recordModel->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$separator = $metaInfo['separator'] ?? ' ';
- Exclude checks
Spaces must 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 ($recordModel->isNew()) {
- Exclude checks
Spaces must 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 $recordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::staticGet(__METHOD__, $recordNumber);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::staticSave(__METHOD__, $recordNumber, $id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null === $state) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->delete($labelTableName, ['crmid' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = $metaInfo[$id]['name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ((new \App\Db\Query())->from($labelTableName)->where(['crmid' => $id])->exists()) {
- 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
$dbCommand->update($labelTableName, ['label' => $label], ['crmid' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $recordId - Record ID
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function updateLabelOnSave(\Vtiger_Record_Model $recordModel): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelName = [];
- 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
$labelName[] = $fieldModel->getDisplayValue($recordModel->get($fieldModel->getName()), $recordModel->getId(), $recordModel, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = TextUtils::textTruncate(trim(implode($separator, $labelName)), 250, false) ?: '';
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$dbCommand->insert('u_#__crmentity_label', ['crmid' => $recordModel->getId(), 'label' => $label])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->insert('u_#__crmentity_search_label', ['crmid' => $recordModel->getId(), 'searchlabel' => $search, 'tabid' => $recordModel->getModule()->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must 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 $state;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get record state.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::get(__METHOD__, $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
$entity = \CRMEntity::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get parent record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$index = $entity->tab_name_index[$field['tablename']];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentId = (new \App\Db\Query())->select(["{$field['tablename']}.{$field['columnname']}"])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(["{$field['tablename']}.{$index}" => $recordId, 'vtiger_crmentity.deleted' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entity = \CRMEntity::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int|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
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = $moduleModel->getCustomLinkLabel($id, $label);
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$label = "<a class=\"modCT_{$moduleName} showReferenceTooltip js-popover-tooltip--record\" href=\"{$url}\">{$label}</a>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->label = \App\Purifier::encodeHtml($label);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get record 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($metadata['deleted'] ?? 3) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(["{$field['tablename']}.{$field['columnname']}" => $recordNumber, 'vtiger_crmentity.deleted' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$labelTableName = \App\RecordSearch::LABEL_TABLE_NAME;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchTableName = \App\RecordSearch::SEARCH_TABLE_NAME;
- 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
$label = $metaInfo[$id]['search'];
- Exclude checks
Spaces must 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
$dbCommand->insert('u_#__crmentity_label', ['crmid' => $recordModel->getId(), 'label' => $label])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($metaInfo['searchcolumnArr'] as $columnName) {
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
return (isset($recordMetaData) && 1 !== $recordMetaData['deleted'] && ($moduleName ? $recordMetaData['setype'] === $moduleName : true)) ? true : 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
$invData = \Vtiger_Inventory_Model::getInventoryDataById($recordId, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state = 'Active';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 2:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$index = $entity->tab_name_index[$field['tablename']];
- Exclude checks
Spaces must 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($moduleName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $recordNumber
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state = self::getState($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::has(__METHOD__, $recordId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = self::getLabel($id, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($label) && 0 != $label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($id && !Privilege::isPermitted($moduleName, 'DetailView', $id)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = static::getType($recordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($parentModules = ModuleHierarchy::getModulesMap1M($moduleName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from($field['tablename'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->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
return $parentId;
- Exclude checks
Spaces must 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|null $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$label = "<a class=\"modCT_{$moduleName} showReferenceTooltip js-popover-tooltip--record\" href=\"{$url}\">{$label}</a>";
- Exclude checks
Spaces must 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 getIdByRecordNumber(string $recordNumber, string $moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|null $length
- Exclude checks
Spaces must 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
->from($field['tablename'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = $moduleModel->getDetailViewUrl($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
return '<i class="color-red-500" title="' . $id . '">' . Language::translate('LBL_RECORD_DOES_NOT_EXIST') . '</i>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null !== $length) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($parentModules as $parentModule) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($field = Field::getRelatedFieldForModule($moduleName, $parentModule)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::staticHas(__METHOD__, $recordNumber)) {
- Exclude checks
Spaces must 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 getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
public static function getHtmlLink(int $id, ?string $moduleName = null, ?int $length = null, bool $fullUrl = false): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$deleted = 'Trash' === $state;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fullUrl) {
- Exclude checks
Spaces must 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