Showing 68 of 68 total issues
Avoid using short method names like Html::ul(). The configured minimum method name length is 3. Open
public static function ul(mixed ...$arguments): self
{
array_unshift($arguments, 'ul');
return self::createElement(...$arguments);
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like Html::h(). The configured minimum method name length is 3. Open
public static function h(string|int $size, string $text): self
{
return self::createElement('h'.$size, $text);
}
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like Html::p(). The configured minimum method name length is 3. Open
public static function p(mixed ...$arguments): self
{
array_unshift($arguments, 'p');
return self::createElement(...$arguments);
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Method addClass
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addClass(array|string|null $value = ''): self
{
if (blank($value)) {
return $this;
}
The class Html has 95 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Html extends Markup
{
/**
* @param string $tag
* @param array<mixed> $arguments
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Method icon
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function icon(string $icon, string|int $size = 0, string $tag = 'i'): self
{
$icon = preg_replace('/(")(.*?)(")/', '$2', $icon);
$icon_array = explode(',', $icon, 2);
Function getNext
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getNext(): ?self
{
$next = null;
$find = false;
if (!is_null($this->parent)) {
- 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 icon
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function icon(string $icon, string|int $size = 0, string $tag = 'i'): self
{
$icon = preg_replace('/(")(.*?)(")/', '$2', $icon);
$icon_array = explode(',', $icon, 2);
- 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 variables with short names like $fa. Configured minimum length is 3. Open
$fa = self::$tag()->addClass('fa'.$type.' fa-fw '.$icon.$size)->aria('hidden', 'true');
- 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
Function routeLink
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function routeLink(
?string $text = null,
?string $route = null,
array $parameters = [],
array $link_attributes = [],
- 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 routeLink
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
?string $text = null,
?string $route = null,
array $parameters = [],
array $link_attributes = [],
string $extra_link = ''
Function getPrevious
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getPrevious(): ?static
{
$prev = $this;
if (!is_null($this->parent)) {
- 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 required has a boolean flag argument $required, which is a certain sign of a Single Responsibility Principle violation. Open
public function required(mixed $required = true, mixed $required_value = true): self
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method attrIf has a boolean flag argument $check, which is a certain sign of a Single Responsibility Principle violation. Open
public function attrIf(?bool $check = false, mixed ...$attr): self
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method checked has a boolean flag argument $value, which is a certain sign of a Single Responsibility Principle violation. Open
public function checked(?bool $value = true, ?bool $check_value = true): self
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method prepareOptions has a boolean flag argument $blank_first_option, which is a certain sign of a Single Responsibility Principle violation. Open
bool $blank_first_option = false,
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method rtl has a boolean flag argument $is_rtl, which is a certain sign of a Single Responsibility Principle violation. Open
public function rtl(bool $is_rtl = false): self
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method s has a boolean flag argument $value, which is a certain sign of a Single Responsibility Principle violation. Open
public function s(\Closure|string|bool|null $value = true): string
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method style has a boolean flag argument $replace, which is a certain sign of a Single Responsibility Principle violation. Open
public function style(?string $value = null, bool $replace = false): self
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method addAttrIf has a boolean flag argument $check, which is a certain sign of a Single Responsibility Principle violation. Open
public function addAttrIf(?bool $check = false, mixed ...$attr): self
- 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) {
}
}