Showing 61 of 61 total issues
Function __call
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
public function __call(string $name, array $arguments)
{
$original_method_name = Str::snake($name);
preg_match('/^([a-z]+)_([a-z_]+)_([a-z]+)$/', $original_method_name, $matches);
- 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
File Item.php
has 463 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* This file is part of Laravel Navigation Builder.
*
Menu
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class Menu
{
/**
* Item collection.
*
Item
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class Item
{
/**
* No link specified.
*
Function render
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function render($menu_level = 0)
{
static::activateIfItemIsActive($this);
// Not authorized for this 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 __call
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __call(string $name, array $arguments)
{
$original_method_name = Str::snake($name);
preg_match('/^([a-z]+)_([a-z_]+)_([a-z]+)$/', $original_method_name, $matches);
The class Menu has 24 public methods. Consider refactoring Menu to keep number of public methods under 10. Open
class Menu
{
/**
* Item collection.
*
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Item has an overall complexity of 132 which is very high. The configured complexity threshold is 50. Open
class Item
{
/**
* No link specified.
*
- Exclude checks
The class Menu has 26 non-getter- and setter-methods. Consider refactoring Menu to keep number of methods under 25. Open
class Menu
{
/**
* Item collection.
*
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class Menu has an overall complexity of 70 which is very high. The configured complexity threshold is 50. Open
class Menu
{
/**
* Item collection.
*
- Exclude checks
The class Item has 22 public methods. Consider refactoring Item to keep number of public methods under 10. Open
class Item
{
/**
* No link specified.
*
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Method render
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render($menu_level = 0)
{
static::activateIfItemIsActive($this);
// Not authorized for this menu.
File Menu.php
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* This file is part of Laravel Navigation Builder.
*
Function activateIfItemIsActive
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function activateIfItemIsActive($item)
{
// No menu items provided.
if (empty($list = $item->getActiveIfItemIsActiveOption())) {
return false;
- 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 getMenu
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getMenu($key)
{
if (is_array($key)) {
$menu_items = $key;
} 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
Consider simplifying this complex logical expression. Open
if (($action == 'add' || $action == 'remove' || $action == 'append' || $action == 'prepend')
&& ($key == 'item' || $key == 'container' || $key == 'link') && $method_name == 'attribute') {
$input_value = Arr::get($arguments, 1, '');
$current_value = Arr::get($this->{$key.'_'.$method_name}, Arr::get($arguments, 0, null), '');
Method renderDropdown
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function renderDropdown()
{
$menu_source = Arr::get($this->option, 'dropdown_source', null);
$config = Arr::get($this->option, 'dropdown_config', null);
Method __call
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __call($name, $arguments)
{
// $this->whereTitle(...)
preg_match('/^[W|w]here([a-zA-Z0-9_]+)$/', $name, $matches);
Function __call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __call($name, $arguments)
{
// $this->whereTitle(...)
preg_match('/^[W|w]here([a-zA-Z0-9_]+)$/', $name, $matches);
- 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 activateIfItemIsActive
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function activateIfItemIsActive($item)
{
// No menu items provided.
if (empty($list = $item->getActiveIfItemIsActiveOption())) {
return false;