Showing 117 of 118 total issues
The class HolidaysList has an overall complexity of 64 which is very high. The configured complexity threshold is 50. Open
class HolidaysList extends MixinBase
{
/**
* @var array
*/
- Exclude checks
The class HolidayCalculator has an overall complexity of 60 which is very high. The configured complexity threshold is 50. Open
class HolidayCalculator extends CalculatorBase
{
use YearCondition;
/**
- Exclude checks
The class HolidaysList has 11 public methods. Consider refactoring HolidaysList to keep number of public methods under 10. Open
class HolidaysList extends MixinBase
{
/**
* @var array
*/
- 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
File HolidaysList.php
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Cmixin\BusinessDay;
use Cmixin\BusinessDay\Util\Context;
File HolidayCalculator.php
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Cmixin\BusinessDay\Calculator;
use Cmixin\BusinessDay;
Avoid excessively long variable names like $missingCalendarExtensionExceptionSkipped. Keep variable name length under 20. Open
private static $missingCalendarExtensionExceptionSkipped = false;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $missingCalendarExtensionExceptionSkipped. Keep variable name length under 20. Open
private static $missingCalendarExtensionExceptionSkipped = false;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Function setHolidaysRegion
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function setHolidaysRegion()
{
$mixin = $this;
/**
- 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 using undefined variables such as '$match' which will lead to PHP notices. Open
$cap = $match[3];
- 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 '$match' which will lead to PHP notices. Open
$every = $match[1];
- 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 '$match' which will lead to PHP notices. Open
if (substr($match[1], -4) === 'leap') {
- 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 '$dateTime' which will lead to PHP notices. Open
? $this->normalizeHolidayDate($key, $holiday, $dateTime ?? null, $year)
- 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 '$match' which will lead to PHP notices. Open
if ($this->consumeHolidayString('/ every (\d+) years (since|until) (\d{4})$/', $holiday, $match)) {
- 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 '$dateTime' which will lead to PHP notices. Open
$holiday = $this->parseHoliday($holiday, $dateTime, $key);
- 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 '$match' which will lead to PHP notices. Open
$mode = $match[2];
- 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 '$match' which will lead to PHP notices. Open
$cap = $match[1] === 'even' ? 0 : 1;
- 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 '$match' which will lead to PHP notices. Open
return (!($this->year % 4) && ($this->year % 100 || !($this->year % 400))) !== ($match[1] === 'leap');
- 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 '$match' which will lead to PHP notices. Open
if ($this->consumeHolidayString('/ of (even|odd|leap|non-leap) years?$/i', $holiday, $match)) {
- 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
Method matchYearCondition
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function matchYearCondition($dateTime, ?string &$condition): bool
{
if (!$condition || !preg_match(
'/^\s*year(?:\s*%\s*(?<modulo>\d+))?\s*(?<operator>>=?|<=?|={1,3}|!={1,2}|<>)\s*(?<expected>\d+)/',
$condition,
Method setHolidaysRegion
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setHolidaysRegion()
{
$mixin = $this;
/**