Function getAllByType
has a Cognitive Complexity of 122 (exceeds 5 allowed). Consider refactoring. Open
public static function getAllByType($tabid, $type = false, $parameters = false)
{
if (\App\Cache::has('AllLinks', 'ByType')) {
$rows = \App\Cache::get('AllLinks', 'ByType');
} else {
- 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 getAllByType
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getAllByType($tabid, $type = false, $parameters = false)
{
if (\App\Cache::has('AllLinks', 'ByType')) {
$rows = \App\Cache::get('AllLinks', 'ByType');
} else {
The class Link has an overall complexity of 57 which is very high. The configured complexity threshold is 50. Open
class Link
{
public $tabid;
public $linkid;
public $linktype;
- Exclude checks
Method addLink
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function addLink($tabid, $type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null, $linkParams = null)
{
$db = \App\Db::getInstance();
if (0 != $tabid) {
$exists = (new \App\Db\Query())->from('vtiger_links')
Method addLink
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function addLink($tabid, $type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null, $linkParams = null)
Function addLink
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function addLink($tabid, $type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null, $linkParams = null)
{
$db = \App\Db::getInstance();
if (0 != $tabid) {
$exists = (new \App\Db\Query())->from('vtiger_links')
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function initialize($valuemap)
{
foreach ($valuemap as $key => $value) {
if (!empty($value) && ('linkurl' == $key || 'linkicon' == $key)) {
$this->{$key} = \App\Purifier::decodeHtml($value);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method getAllByType() has 112 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public static function getAllByType($tabid, $type = false, $parameters = false)
{
if (\App\Cache::has('AllLinks', 'ByType')) {
$rows = \App\Cache::get('AllLinks', 'ByType');
} else {
- Exclude checks
The method getAllByType() has an NPath complexity of 16524. The configured NPath complexity threshold is 200. Open
public static function getAllByType($tabid, $type = false, $parameters = false)
{
if (\App\Cache::has('AllLinks', 'ByType')) {
$rows = \App\Cache::get('AllLinks', 'ByType');
} else {
- 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 getAllByType() has a Cyclomatic Complexity of 36. The configured cyclomatic complexity threshold is 10. Open
public static function getAllByType($tabid, $type = false, $parameters = false)
{
if (\App\Cache::has('AllLinks', 'ByType')) {
$rows = \App\Cache::get('AllLinks', 'ByType');
} else {
- 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
This function has 8 parameters, which is greater than the 7 authorized. Open
public static function addLink($tabid, $type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null, $linkParams = null)
- Read upRead up
- Exclude checks
A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.
Noncompliant Code Example
With a maximum number of 4 parameters:
function doSomething($param1, $param2, $param3, $param4, $param5) { ... }
Compliant Solution
function doSomething($param1, $param2, $param3, $param4) { ... }
Refactor this function to reduce its Cognitive Complexity from 125 to the 15 allowed. Open
public static function getAllByType($tabid, $type = false, $parameters = false)
- 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 method getAllByType has a boolean flag argument $type, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getAllByType($tabid, $type = false, $parameters = 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 '290', column '22'). Open
$dataReader = (new \App\Db\Query())->from('vtiger_links')
- 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 '314', column '20'). Open
$linkData = (new \App\Db\Query())->from('vtiger_links')->where(['linkid' => $linkId])->one();
- 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 deleteLink has a boolean flag argument $url, which is a certain sign of a Single Responsibility Principle violation. Open
public static function deleteLink($tabid, $type, $label, $url = 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 '84', column '19'). Open
$exists = (new \App\Db\Query())->from('vtiger_links')
- 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 '175', column '24'). Open
$linksFromDb = (new \App\Db\Query())->from('vtiger_links')->all();
- 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 '244', column '22'). Open
$strtemplate = new \Vtiger_StringTemplate();
- 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 getAllByType has a boolean flag argument $parameters, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getAllByType($tabid, $type = false, $parameters = 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
Avoid using static access to class '\App\Db' in method 'deleteLink'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getLinkData'. Open
return \App\Cache::get('Link', $linkId);
- 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 'getAllByType'. Open
\App\Cache::save('AllLinks', 'ByType', $rows);
- 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\Deprecated' in method 'getAllByType'. Open
if (!empty($row['handler_path']) && \vtlib\Deprecated::isFileAccessible($row['handler_path'])) {
- 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 initialize uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->{$key} = $value;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getAllByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$linksFromDb = (new \App\Db\Query())->from('vtiger_links')->all();
$rows = [];
foreach ($linksFromDb as $row) {
$rows[$row['tabid']][$row['linktype']][] = $row;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Purifier' in method 'initialize'. Open
$this->{$key} = \App\Purifier::decodeHtml($value);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getAllByType'. Open
$rows = \App\Cache::get('AllLinks', 'ByType');
- 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 getAllByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($rows[$tabid] as $linkType) {
foreach ($linkType as $data) {
$links[] = $data;
}
- 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\Log' in method 'deleteLink'. Open
\App\Log::trace("Deleting Link ($type - $label - $url) ... DONE");
- 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 'getLinkData'. Open
\App\Cache::save('Link', $linkId, $linkData);
- 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 deleteLink uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$db->createCommand()->delete('vtiger_links', [
'tabid' => $tabid,
'linktype' => $type,
'linklabel' => $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
The method getAllByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (self::IGNORE_MODULE === $tabid) {
foreach ($rows as $row) {
if (isset($row[$type])) {
foreach ($row[$type] as $data) {
- 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 getAllByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (isset($rows[0][$type])) {
foreach ($rows[0][$type] as $data) {
$links[] = $data;
}
- 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\Log' in method 'addLink'. Open
\App\Log::trace("Adding Link ($type - $label) ... DONE");
- 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 'deleteLink'. Open
\App\Cache::delete('AllLinks', 'ByType');
- 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 'module'. Open
return \App\Module::getModuleName($this->tabid);
- 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\Log' in method 'deleteAll'. Open
\App\Log::trace('Deleting Links ... DONE');
- 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 'getAllByType'. Open
if (\App\Cache::has('AllLinks', 'ByType')) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'addLink'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'deleteLink'. Open
\App\Log::trace("Deleting Link ($type - $label) ... DONE");
- 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 'deleteAll'. Open
\App\Cache::delete('AllLinks', 'ByType');
- 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 'getLinkData'. Open
if (\App\Cache::has('Link', $linkId)) {
- 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 'addLink'. Open
\App\Cache::delete('AllLinks', 'ByType');
- 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\Deprecated' in method 'getAllByType'. Open
$permittedTabIdList = \App\User::getCurrentUserId() ? \vtlib\Deprecated::getPermittedModuleIdList() : [];
- 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\Deprecated' in method 'getAllByType'. Open
\vtlib\Deprecated::checkFileAccessForInclusion($row['handler_path']);
- 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 getAllByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$instances[$instance->linktype] = $instance;
}
- 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\User' in method 'getAllByType'. Open
$permittedTabIdList = \App\User::getCurrentUserId() ? \vtlib\Deprecated::getPermittedModuleIdList() : [];
- 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 getAllByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($type as $typeLink) {
if (isset($rows[0][$typeLink])) {
foreach ($rows[0][$typeLink] as $data) {
$links[] = $data;
- 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\Log' in method 'getAllByType'. Open
\App\Log::trace('Ignoring Link ... ' . var_export($row, 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
Define a constant instead of duplicating this literal "linkicon" 3 times. Open
if (!empty($value) && ('linkurl' == $key || 'linkicon' == $key)) {
- 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 "ByType" 6 times. Open
\App\Cache::delete('AllLinks', 'ByType');
- 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 "linkurl" 4 times. Open
if (!empty($value) && ('linkurl' == $key || 'linkicon' == $key)) {
- 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 "handler_path" 5 times. Open
$params['handler_path'] = $handlerInfo['path'] ?? null;
- 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 "vtiger_links" 8 times. Open
$exists = (new \App\Db\Query())->from('vtiger_links')
- 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 "tabid" 7 times. Open
->where(['tabid' => $tabid, 'linktype' => $type, 'linkurl' => $url, 'linkicon' => $iconpath, 'linklabel' => $label])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linktype" 5 times. Open
->where(['tabid' => $tabid, 'linktype' => $type, 'linkurl' => $url, 'linkicon' => $iconpath, 'linklabel' => $label])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linklabel" 4 times. Open
->where(['tabid' => $tabid, 'linktype' => $type, 'linkurl' => $url, 'linkicon' => $iconpath, 'linklabel' => $label])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "AllLinks" 6 times. Open
\App\Cache::delete('AllLinks', 'ByType');
- 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.
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
\App\Cache::save('Link', $linkId, $linkData);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_links', [
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Deleting Link ($type - $label) ... DONE");
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Deleting Link ($type - $label - $url) ... DONE");
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_links', [
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Adding Link ($type - $label) ... DONE");
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$permittedTabIdList = \App\User::getCurrentUserId() ? \vtlib\Deprecated::getPermittedModuleIdList() : [];
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Ignoring Link ... ' . var_export($row, true));
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (\App\Cache::has('Link', $linkId)) {
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$exists = (new \App\Db\Query())->from('vtiger_links')
- Exclude checks
Default value for array
$parameters
can't be false
Open
public static function getAllByType($tabid, $type = false, $parameters = false)
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
return \App\Cache::get('Link', $linkId);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$linkData = (new \App\Db\Query())->from('vtiger_links')->where(['linkid' => $linkId])->one();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Deleting Links ... DONE');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new \App\Db\Query())->from('vtiger_links')
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$linksFromDb = (new \App\Db\Query())->from('vtiger_links')->all();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_links', $params)->execute();
- Exclude checks
Default value for string
$url
can't be false
Open
public static function deleteLink($tabid, $type, $label, $url = false)
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->delete('vtiger_links', ['tabid' => $tabid])->execute();
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 14. Open
<?php
- Exclude checks
The property $__cacheSchemaChanges is not named in camelCase. Open
class Link
{
public $tabid;
public $linkid;
public $linktype;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $handler_class is not named in camelCase. Open
class Link
{
public $tabid;
public $linkid;
public $linktype;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $handler_path is not named in camelCase. Open
class Link
{
public $tabid;
public $linkid;
public $linktype;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Property name "$__cacheSchemaChanges" should not be prefixed with an underscore to indicate visibility Open
public static $__cacheSchemaChanges = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $linkid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $tabid Module ID
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => $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
* @param array $valuemap
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($value) && ('linkurl' == $key || 'linkicon' == $key)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($this->tabid)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array|null $handlerInfo
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
->where(['tabid' => $tabid, 'linktype' => $type, 'linkurl' => $url, 'linkicon' => $iconpath, 'linklabel' => $label])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Ignore module while selection
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Initialize this instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($valuemap as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add link given module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $url HREF value or URL to use for the link
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => $type,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type Link Type (like DETAIL_VIEW_BASIC). Useful for grouping based on pages
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $url URL of link to lookup while deleting
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => $type,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $linkicon;
- Exclude checks
Spaces must 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 $iconpath ICON to use on the display
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 != $tabid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exists = (new \App\Db\Query())->from('vtiger_links')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => $label,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $status = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $params;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function module()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $label Label to display
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $sequence Order or sequence of displaying the link
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
public static function addLink($tabid, $type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null, $linkParams = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => $type,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $linktype;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Adding Link ($type - $label) ... DONE");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete link of the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($url) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $url,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_links', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->delete('vtiger_links', ['tabid' => $tabid])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permittedTabIdList = \App\User::getCurrentUserId() ? \vtlib\Deprecated::getPermittedModuleIdList() : [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rows[$moduleId][$typ])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instances[$t] = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Ignoring Link ... ' . var_export($row, 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
public $handler_path;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->{$key} = \App\Purifier::decodeHtml($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['tabid' => $tabid, 'linktype' => $type, 'linkurl' => $url, 'linkicon' => $iconpath, 'linklabel' => $label])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->exists();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $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
Spaces must 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 $tabid Module 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows as $row) {
- Exclude checks
Spaces must 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 ($parameters as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ignore = \call_user_func([$row['handler_class'], $row['handler']], $linkData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = $instance;
- Exclude checks
Spaces must 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
'tabid' => $tabid,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['handler'] = $handlerInfo['method'] ?? 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
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('AllLinks', 'ByType');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get all the link related to module based on type.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $type String or List of types to select
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($linksFromDb as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->initialize($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\vtlib\Deprecated::checkFileAccessForInclusion($row['handler_path']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->from('vtiger_links')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 == $tabid || !$exists) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => $iconpath,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('AllLinks', 'ByType');
- Exclude checks
Spaces must 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 deleteLink($tabid, $type, $label, $url = 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rows[$tabid][$typeLink])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = $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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($type)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (self::IGNORE_MODULE === $tabid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($type as $typ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows[$tabid][$typeLink] as $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($multitype) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instances;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->initialize($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tabid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $handler_class;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Cache (Record) the schema changes to improve performance */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->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
\App\Log::trace('Deleting Links ... DONE');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $tabid Module ID
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_links', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Deleting Link ($type - $label - $url) ... DONE");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows = \App\Cache::get('AllLinks', 'ByType');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linksFromDb = (new \App\Db\Query())->from('vtiger_links')->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$multitype = true;
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$permittedTabIdList = \App\User::getCurrentUserId() ? \vtlib\Deprecated::getPermittedModuleIdList() : [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($row[$type] as $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
public static function getAll($tabid)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows[0][$type] as $data) {
- 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
$strtemplate->assign($key, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($permittedTabIdList as $moduleId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($type as $typeLink) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows[0][$typeLink] as $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $tabid
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $handler;
- 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 \App\Module::getModuleName($this->tabid);
- Exclude checks
Spaces must 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 $__cacheSchemaChanges = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type Link Type (like DETAIL_VIEW_BASIC). Useful for grouping based on pages
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sequence' => (int) $sequence,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['handler_path'] = $handlerInfo['path'] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['handler_class'] = $handlerInfo['class'] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_links', $params)->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
foreach ($rows[$tabid] as $linkType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($links as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$ignore) {
- 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
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must 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 $linkParams
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($handlerInfo)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($linkParams)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $label Display label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => $tabid,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete all links related to module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get all the links related to module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save('AllLinks', 'ByType', $rows);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permittedTabIdList[] = 0; // Added to support one link for all modules
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require_once $row['handler_path'];
- Exclude checks
Spaces must 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 ($parameters) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Cache::has('AllLinks', 'ByType')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows[$row['tabid']][$row['linktype']][] = $row;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = $data;
- 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
public $linkurl;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $icon;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const IGNORE_MODULE = -1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->{$key} = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => $label,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['params'] = $linkParams;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => $tabid,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Deleting Link ($type - $label) ... DONE");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$multitype = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows[$moduleId][$typ] as $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rows[0][$typeLink])) {
- Exclude checks
Spaces must 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 ($rows[$tabid][$type] as $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
if ($parameters) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($type as $t) {
- Exclude checks
Spaces must 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($row['handler_path']) && \vtlib\Deprecated::isFileAccessible($row['handler_path'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = $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
if (isset($rows[$tabid][$type])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAllForExport($tabid)
- 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
return $links;
- Exclude checks
Spaces must 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 $linklabel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $sequence;
- Exclude checks
Spaces must 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 addLink($tabid, $type, $label, $url, $iconpath = '', $sequence = 0, $handlerInfo = null, $linkParams = 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
public static function deleteAll($tabid)
- Exclude checks
Spaces must 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 $tabid Module ID
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAllByType($tabid, $type = false, $parameters = 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
$links[] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($linkType as $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$strtemplate = new \Vtiger_StringTemplate();
- Exclude checks
Spaces must 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
$links[] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['tabid' => $tabid])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Link 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
$instances = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkData = new LinkData($instance);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($multitype) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instances[$instance->linktype][] = $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function initialize($valuemap)
- Exclude checks
Spaces must 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
\App\Cache::delete('AllLinks', 'ByType');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::getAllByType($tabid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($row[$type])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->linkicon = $strtemplate->merge($instance->linkicon);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instances[$instance->linktype] = $instance;
- Exclude checks
Spaces must 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 $tabid Module 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
* @param array $parameters Map Key-Value pair to use for formating the link 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (self::IGNORE_MODULE === $tabid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rows[0][$type])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->linkurl = $strtemplate->merge($instance->linkurl);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Extract the links of module for export.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkData = (new \App\Db\Query())->from('vtiger_links')->where(['linkid' => $linkId])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $linkData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLinkData($linkId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must 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 $linkId
- Exclude checks
Spaces must 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
\App\Cache::save('Link', $linkId, $linkData);
- Exclude checks
Spaces must 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 (\App\Cache::has('Link', $linkId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Cache::get('Link', $linkId);
- Exclude checks