Function getBreadcrumbs
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
public static function getBreadcrumbs($pageTitle = false)
{
$breadcrumbs = [];
$request = App\Request::init();
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 getBreadcrumbs
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getBreadcrumbs($pageTitle = false)
{
$breadcrumbs = [];
$request = App\Request::init();
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
The class Vtiger_Menu_Model has an overall complexity of 78 which is very high. The configured complexity threshold is 50. Open
class Vtiger_Menu_Model
{
/**
* Static Function to get all the accessible menu models with/without ordering them by sequence.
*
- Exclude checks
Function getMenuIcon
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function getMenuIcon($menu, $title = ''): string
{
if (empty($title) && !empty($menu['label'])) {
$title = self::getLabelToDisplay($menu);
}
- 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 getLabelToDisplay
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getLabelToDisplay(array $row): string
{
$name = '';
$type = $row['type'];
if (\is_int($type)) {
Function getLabelToDisplay
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function getLabelToDisplay(array $row): string
{
$name = '';
$type = $row['type'];
if (\is_int($type)) {
- 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
Avoid too many return
statements within this method. Open
return '<span class="c-menu__item__icon yfm-' . $menu['mod'] . '" aria-hidden="true"></span>';
Avoid too many return
statements within this method. Open
return '';
The method getMenuIcon() has an NPath complexity of 675. The configured NPath complexity threshold is 200. Open
public static function getMenuIcon($menu, $title = ''): string
{
if (empty($title) && !empty($menu['label'])) {
$title = self::getLabelToDisplay($menu);
}
- 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 getBreadcrumbs() has an NPath complexity of 39640. The configured NPath complexity threshold is 200. Open
public static function getBreadcrumbs($pageTitle = false)
{
$breadcrumbs = [];
$request = App\Request::init();
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 getBreadcrumbs() has 112 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public static function getBreadcrumbs($pageTitle = false)
{
$breadcrumbs = [];
$request = App\Request::init();
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- Exclude checks
The method getMenuIcon() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. Open
public static function getMenuIcon($menu, $title = ''): string
{
if (empty($title) && !empty($menu['label'])) {
$title = self::getLabelToDisplay($menu);
}
- 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 getBreadcrumbs() has a Cyclomatic Complexity of 42. The configured cyclomatic complexity threshold is 10. Open
public static function getBreadcrumbs($pageTitle = false)
{
$breadcrumbs = [];
$request = App\Request::init();
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 getLabelToDisplay() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function getLabelToDisplay(array $row): string
{
$name = '';
$type = $row['type'];
if (\is_int($type)) {
- 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 6, down to the maximum allowed 3. Open
public static function getMenuIcon($menu, $title = ''): 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 73 to the 15 allowed. Open
public static function getBreadcrumbs($pageTitle = 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
Avoid using undefined variables such as '$menus' which will lead to PHP notices. Open
if (empty($menus)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$menus' which will lead to PHP notices. Open
$url = $menus[$mid]['dataurl'] ?? $parentList[$mid]['dataurl'] ?? $moduleModel->getDefaultUrl();
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$menus' which will lead to PHP notices. Open
if (0 === \count($menus)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$menus' which will lead to PHP notices. Open
return \Settings_Menu_Record_Model::parseToDisplay($menus);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The method getBreadcrumbs has a boolean flag argument $pageTitle, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getBreadcrumbs($pageTitle = 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\Language' in method 'getBreadcrumbs'. Open
'name' => \App\Language::translate($moduleName, $moduleName),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Language' in method 'getBreadcrumbs'. Open
'name' => App\Language::translate($menuModel->get('name'), $qualifiedModuleName),
- 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\Request' in method 'getBreadcrumbs'. Open
$request = App\Request::init();
- 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 'Users_Privileges_Model' in method 'getBreadcrumbs'. Open
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 'getBreadcrumbs'. 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
The method getBreadcrumbs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
require 'user_privileges/menu_0.php';
}
- 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 'Settings_Vtiger_MenuItem_Model' in method 'getBreadcrumbs'. Open
$menu = Settings_Vtiger_MenuItem_Model::getAll();
- 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 getAll uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
require 'user_privileges/menu_0.php';
}
- 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 'getBreadcrumbs'. Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_HOME', $moduleName)];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getBreadcrumbs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($pageTitle) {
$breadcrumbs[] = ['name' => App\Language::translate($pageTitle, $qualifiedModuleName)];
} elseif ('Edit' === $view && $request->isEmpty('record') && $request->isEmpty('parent_roleid')) {
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_CREATE', $qualifiedModuleName)];
- 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 'getBreadcrumbs'. Open
$breadcrumbs[] = ['name' => App\Language::translate($pageTitle, $qualifiedModuleName)];
- 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 'getLabelToDisplay'. 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\Language' in method 'getBreadcrumbs'. Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_CREATE', $qualifiedModuleName)];
- 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 'vtranslateMenu'. Open
return \App\Language::translate($key, $module);
- 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 'getBreadcrumbs'. Open
'name' => \App\Language::translate('LBL_VIEW_SETTINGS', $qualifiedModuleName),
- 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_Theme' in method 'getMenuIcon'. Open
$icon = \Vtiger_Theme::getImagePath($menu['icon']);
- 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 'getBreadcrumbs'. Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_CREATE', $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\Owner' in method 'getBreadcrumbs'. Open
$recordLabel = \App\Fields\Owner::getUserLabel($request->getInteger('record'));
- 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 '\Settings_Menu_Record_Model' in method 'getAll'. Open
return \Settings_Menu_Record_Model::parseToDisplay($menus);
- 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 getBreadcrumbs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$breadcrumbs[] = [
'name' => \App\Language::translate($moduleName, $moduleName),
];
}
- 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 'getBreadcrumbs'. Open
'name' => \App\Language::translate($moduleName, $moduleName),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Language' in method 'getBreadcrumbs'. Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_' . strtoupper($view), $moduleName)];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getBreadcrumbs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$url = $moduleModel->getDefaultUrl();
}
- 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 'vtranslateMenu'. Open
$string = \App\Language::translateSingleMod($key, 'Other.Menu');
- 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 'getBreadcrumbs'. Open
$recordLabel = vtlib\Functions::getCRMRecordLabel($request->getInteger('record'));
- 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_Theme' in method 'getMenuIcon'. Open
$iconName = \Vtiger_Theme::getImagePath($menu);
- 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 'Users_Privileges_Model' in method 'getAll'. Open
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 'getBreadcrumbs'. Open
'name' => App\Language::translate($parent->getLabel(), $qualifiedModuleName),
- 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 getLabelToDisplay uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$name = \App\Language::translate('LBL_QUICK_CREATE_MODULE', 'Menu') . ': ' . self::vtranslateMenu('SINGLE_' . $moduleName, $moduleName);
}
- 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 'getLabelToDisplay'. Open
$name = \App\Language::translate('LBL_QUICK_CREATE_MODULE', 'Menu') . ': ' . self::vtranslateMenu('SINGLE_' . $moduleName, $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\CustomView' in method 'getLabelToDisplay'. Open
$data = \App\CustomView::getCustomViewById($cvid);
- 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 'getLabelToDisplay'. Open
$name = self::vtranslateMenu($data['entitytype'], $data['entitytype']) . ': ' . \App\Language::translate($data['viewname'], $data['entitytype']);
- 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 getLabelToDisplay uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$moduleName = $row['mod'] ?? '';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Define a constant instead of duplicating this literal "dataurl" 5 times. Open
$url = $menus[$mid]['dataurl'] ?? $parentList[$mid]['dataurl'] ?? $moduleModel->getDefaultUrl();
- 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 "Alnum" 3 times. Open
$view = $request->getByType('view', 'Alnum');
- 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 "record" 7 times. Open
} elseif ('Edit' === $view && $request->isEmpty('record')) {
- 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 "entitytype" 3 times. Open
$name = self::vtranslateMenu($data['entitytype'], $data['entitytype']) . ': ' . \App\Language::translate($data['viewname'], $data['entitytype']);
- 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
if (empty($title) && !empty($menu['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 "user_privileges/menu_0.php" 4 times. Open
require 'user_privileges/menu_0.php';
- 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 "parent" 6 times. Open
$parent = $request->getByType('parent', 'Alnum');
- 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 method getUserLabel
from undeclared class \App\Fields\Owner
Open
$recordLabel = \App\Fields\Owner::getUserLabel($request->getInteger('record'));
- Exclude checks
Variable $menus
is undeclared Open
if (0 === \count($menus)) {
- Exclude checks
Variable $parentList
is undeclared Open
$parentMenu = self::getParentMenu($parentList, $parent, $moduleName);
- Exclude checks
Variable $parentList
is undeclared Open
$url = $menus[$mid]['dataurl'] ?? $parentList[$mid]['dataurl'] ?? $moduleModel->getDefaultUrl();
- Exclude checks
Argument 2 (emptyFunction)
is 'Alnum'
but \App\Request::isEmpty()
takes bool|false
defined at /code/app/Request.php:577
Open
$mid = $request->isEmpty('mid', 'Alnum') ? null : $request->getInteger('mid');
- Exclude checks
Variable $menus
is undeclared Open
return \Settings_Menu_Record_Model::parseToDisplay($menus);
- Exclude checks
Variable $parentList
is undeclared Open
$parent = (!$parent && $mid) ? ($parentList[$mid]['parent'] ?? null) : $parent;
- Exclude checks
Variable $parentList
is undeclared Open
foreach ($parentList as &$parentItem) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_Menu_Model
- Exclude checks
The class Vtiger_Menu_Model is not named in CamelCase. Open
class Vtiger_Menu_Model
{
/**
* Static Function to get all the accessible menu models with/without ordering them by sequence.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
require 'user_privileges/menu_0.php';
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$roleMenu = 'user_privileges/menu_' . filter_var($userPrivModel->get('roleid'), FILTER_SANITIZE_NUMBER_INT) . '.php';
- Exclude checks
Spaces must 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 ('AppComponents' !== $moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'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
public static function vtranslateMenu($key, $module)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Language::translate($key, $module);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = $moduleModel->getDefaultUrl();
- Exclude checks
Spaces must 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 ($pageTitle) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleMenu = 'user_privileges/menu_' . filter_var($userPrivModel->get('roleid'), FILTER_SANITIZE_NUMBER_INT) . '.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require $roleMenu;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($string !== $key) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentMenu = self::getParentMenu($parentList, $parent, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => \App\Language::translate($moduleName, $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
} elseif ('Settings' === $parent) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAll(): array
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$roleMenu = 'user_privileges/menu_' . filter_var($userPrivModel->get('roleid'), FILTER_SANITIZE_NUMBER_INT) . '.php';
- 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
$breadcrumbs[] = ['name' => $pageTitle];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_' . strtoupper($view), $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (empty($view)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = ['name' => $recordLabel];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu as $menuModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| $menuModel->isSelected($moduleName, $view, $request->getMode())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($pageTitle as $title) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getParentMenu($parentList, $parent, $module, $return = []): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'url' => $parentList[$parent]['dataurl'],
- Exclude checks
Spaces must 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
$data = \App\CustomView::getCustomViewById($cvid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::vtranslateMenu($data['entitytype'], $data['entitytype']) . ': ' . \App\Language::translate($data['viewname'], $data['entitytype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($menus)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Settings' !== $parent) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($parent)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($parentList as &$parentItem) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($recordLabel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => \App\Language::translate('LBL_VIEW_SETTINGS', $qualifiedModuleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => App\Language::translate($menuModel->get('name'), $qualifiedModuleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'url' => $menuModel->getUrl(),
- Exclude checks
Line exceeds 120 characters; contains 247 characters Open
if (false !== strpos($menu['icon'], 'adminIcon-') || false !== strpos($menu['icon'], 'AdditionalIcon-') || false !== strpos($menu['icon'], 'yfi-') || false !== strpos($menu['icon'], 'yfm-') || false !== strpos($menu['icon'], 'mdi-')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '<span class="c-menu__item__icon ' . $menu['icon'] . '" aria-hidden="true"></span>';
- Exclude checks
Spaces must 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 '<span class="c-menu__item__icon yfm-' . $menu['mod'] . '" aria-hidden="true"></span>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'QuickCreate':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::vtranslateMenu($moduleName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Static Function to get all the accessible menu models with/without ordering them by sequence.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = [
- Exclude checks
Spaces must 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
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
if (\is_array($pageTitle)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('Edit' === $view && $request->isEmpty('record') && $request->isEmpty('parent_roleid')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$title = self::getLabelToDisplay($menu);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '<img src="' . $icon . '" alt="' . $title . '" title="' . $title . '" class="c-menu__item__icon" />';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = \App\Menu::TYPES[$type];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::vtranslateMenu($row['label'], 'Menu');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = \App\Language::translate('LBL_QUICK_CREATE_MODULE', 'Menu') . ': ' . self::vtranslateMenu('SINGLE_' . $moduleName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = App\Request::init();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require $roleMenu;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule();
- 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
'name' => \App\Language::translate($moduleName, $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
$breadcrumbs[] = ['name' => App\Language::translate('LBL_HOME', $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
'url' => 'index.php?module=Vtiger&parent=Settings&view=Index',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Separator':
- 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
} 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
$parent = (!$parent && $mid) ? ($parentList[$mid]['parent'] ?? null) : $parent;
- 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
$breadcrumbs[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'icon' => 'fas fa-cog fa-fw',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = $title;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get icon of element in menu.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'HomeIcon':
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$cvid = \is_int($row['type']) ? $row['dataurl'] : vtlib\Functions::getQueryParams($row['dataurl'])['viewname'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$string = \App\Language::translateSingleMod($key, 'Other.Menu');
- 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
return $string;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require 'user_privileges/menu_0.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs = array_reverse($parentMenu);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($moduleModel && $moduleModel->getDefaultUrl()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($mid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$return[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 !== $parentList[$parent]['parent'] && \array_key_exists($parentList[$parent]['parent'], $parentList)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '<img src="' . $iconName . '" alt="' . $title . '" title="' . $title . '" class="c-menu__item__icon" />';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLabelToDisplay(array $row): string
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'CustomFilter':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($roleMenu)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require 'user_privileges/menu_0.php';
- Exclude checks
Spaces must 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 (\count($parentMenu) > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = $menus[$mid]['dataurl'] ?? $parentList[$mid]['dataurl'] ?? $moduleModel->getDefaultUrl();
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
(($request->has('record') || 'Edit' === $view) && $menuModel->getModuleName() === $qualifiedModuleName)
- Exclude checks
Spaces must 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|array $menu
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_string($menu)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '<span class="' . $menu['icon'] . ' c-menu__item__icon"></span>';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($menu['type']) && 'Module' === $menu['type']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get label to display.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' != $row['label']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::vtranslateMenu($row['label'], 'Menu');
- Exclude checks
Spaces must 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 (0 === \count($menus)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \Settings_Menu_Record_Model::parseToDisplay($menus);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($moduleName === $parentItem['mod']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (!empty($view) && 'index' !== $view && 'Index' !== $view) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($moduleModel && !$request->isEmpty('record', true) && $moduleModel->isEntityModule()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = [
- Exclude checks
Spaces must 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
$breadcrumbs[] = ['name' => App\Language::translate($pageTitle, $qualifiedModuleName)];
- Exclude checks
Spaces must 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 '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::vtranslateMenu('LBL_SEPARATOR', 'Menu');
- Exclude checks
Spaces must 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 'user_privileges/menu_0.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$view = $request->getByType('view', 'Alnum');
- 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
} elseif ('Edit' === $view && $request->isEmpty('record')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordLabel = vtlib\Functions::getCRMRecordLabel($request->getInteger('record'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_CREATE', $qualifiedModuleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$return = self::getParentMenu($parentList, $parentList[$parent]['parent'], $module, $return);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getBreadcrumbs($pageTitle = 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
$recordLabel = \App\Fields\Owner::getUserLabel($request->getInteger('record'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($title) && !empty($menu['label'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$iconName = \Vtiger_Theme::getImagePath($menu);
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
return '<img src="' . $icon . '" alt="' . $title . '" title="' . $title . '" class="c-menu__item__icon" />';
- Exclude checks
Spaces must 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
case 'RecycleBin':
- Exclude checks
Spaces must 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
$roleMenu = 'user_privileges/menu_' . filter_var($userPrivModel->get('roleid'), FILTER_SANITIZE_NUMBER_INT) . '.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($roleMenu)) {
- Exclude checks
Spaces must 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 ($menuModel->isPermitted() && (
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => App\Language::translate($parent->getLabel(), $qualifiedModuleName),
- Exclude checks
Spaces must 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
$name = '';
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
$name = self::vtranslateMenu($data['entitytype'], $data['entitytype']) . ': ' . \App\Language::translate($data['viewname'], $data['entitytype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parent = $request->getByType('parent', 'Alnum');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mid = $request->isEmpty('mid', 'Alnum') ? null : $request->getInteger('mid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parent = $parentItem['parent'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menu = Settings_Vtiger_MenuItem_Model::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $breadcrumbs;
- Exclude checks
Spaces must 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 ($icon) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Module':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = ['name' => App\Language::translate('LBL_VIEW_CREATE', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$qualifiedModuleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'icon' => $parent->get('icon'),
- Exclude checks
Spaces must 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 (!$request->isEmpty('record') && 'Users' === $moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($menu['icon'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($menu['icon'], 'adminIcon-') || false !== strpos($menu['icon'], 'AdditionalIcon-') || false !== strpos($menu['icon'], 'yfi-') || false !== strpos($menu['icon'], 'yfm-') || false !== strpos($menu['icon'], 'mdi-')) {
- Exclude checks
Spaces must 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
$moduleName = $row['mod'] ?? '';
- 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
if ($pageTitle) {
- 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 (!empty($parent) && !empty($parentList[$parent])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => self::getLabelToDisplay($parentList[$parent]),
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
if (0 !== $parentList[$parent]['parent'] && \array_key_exists($parentList[$parent]['parent'], $parentList)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$icon = \Vtiger_Theme::getImagePath($menu['icon']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = $row['type'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_int($type)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Line exceeds 120 characters; contains 156 characters Open
$name = \App\Language::translate('LBL_QUICK_CREATE_MODULE', 'Menu') . ': ' . self::vtranslateMenu('SINGLE_' . $moduleName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::vtranslateMenu('LBL_HOME', 'Menu');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cvid = \is_int($row['type']) ? $row['dataurl'] : vtlib\Functions::getQueryParams($row['dataurl'])['viewname'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'icon' => $menuModel->get('iconpath'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$breadcrumbs[] = ['name' => $recordLabel];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getMenuIcon($menu, $title = ''): string
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
return '<img src="' . $iconName . '" alt="' . $title . '" title="' . $title . '" class="c-menu__item__icon" />';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($menu['icon'], 'fa-')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $row
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $row['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
$name = self::vtranslateMenu((empty($row['label']) ? $moduleName : $row['label']), $moduleName);
- 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
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(($request->has('record') || 'Edit' === $view) && $menuModel->getModuleName() === $qualifiedModuleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parent = $menuModel->getBlock();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($recordLabel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $title
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($iconName)) {
- Exclude checks
Spaces must 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
break;
- Exclude checks
Class name "Vtiger_Menu_Model" is not in camel caps format Open
class Vtiger_Menu_Model
- Exclude checks