Method render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->ratio) {
$domElement->setAttribute("ratio", $this->ratio);
Function render
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->ratio) {
$domElement->setAttribute("ratio", $this->ratio);
- 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 render() has an NPath complexity of 256. The configured NPath complexity threshold is 200. Open
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->ratio) {
$domElement->setAttribute("ratio", $this->ratio);
- 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
Class constants must be uppercase; expected STYLE_PROGRESSBAR but found STYLE_ProgressBar Open
const STYLE_ProgressBar = "ProgressBar";
- Exclude checks
Class constants must be uppercase; expected STYLE_PROGRESSBARSMALL but found STYLE_ProgressBarSmall Open
const STYLE_ProgressBarSmall = "ProgressBarSmall";
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Class constants must be uppercase; expected STYLE_BGCARD but found STYLE_BgCard Open
const STYLE_BgCard = "BgCard";
- Exclude checks
Class constants must be uppercase; expected STYLE_ENERGYBAR but found STYLE_EnergyBar Open
const STYLE_EnergyBar = "EnergyBar";
- Exclude checks
The 'getCentered()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public function getCentered()
{
return $this->centered;
}
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
The 'getDrawBlockBackground()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public function getDrawBlockBackground()
{
return $this->drawBlockBackground;
}
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
The 'getDrawBackground()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public function getDrawBackground()
{
return $this->drawBackground;
}
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
Constant STYLE_ProgressBar should be defined in uppercase Open
const STYLE_ProgressBar = "ProgressBar";
- Read upRead up
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}
Source https://phpmd.org/rules/naming.html#constantnamingconventions
Constant STYLE_ProgressBarSmall should be defined in uppercase Open
const STYLE_ProgressBarSmall = "ProgressBarSmall";
- Read upRead up
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}
Source https://phpmd.org/rules/naming.html#constantnamingconventions
Constant STYLE_BgCard should be defined in uppercase Open
const STYLE_BgCard = "BgCard";
- Read upRead up
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}
Source https://phpmd.org/rules/naming.html#constantnamingconventions
Constant STYLE_EnergyBar should be defined in uppercase Open
const STYLE_EnergyBar = "EnergyBar";
- Read upRead up
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}