The method equals uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return false;
}
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class HWDevice
- Exclude checks
The property $_serial is not named in camelCase. Open
class HWDevice
{
/**
* name of the device
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_manufacturer is not named in camelCase. Open
class HWDevice
{
/**
* name of the device
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_product is not named in camelCase. Open
class HWDevice
{
/**
* name of the device
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_name is not named in camelCase. Open
class HWDevice
{
/**
* name of the device
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_capacity is not named in camelCase. Open
class HWDevice
{
/**
* name of the device
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_count is not named in camelCase. Open
class HWDevice
{
/**
* name of the device
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Property name "$_product" should not be prefixed with an underscore to indicate visibility Open
private $_product = null;
- Exclude checks
Property name "$_count" should not be prefixed with an underscore to indicate visibility Open
private $_count = 1;
- Exclude checks
Property name "$_capacity" should not be prefixed with an underscore to indicate visibility Open
private $_capacity = null;
- Exclude checks
Property name "$_serial" should not be prefixed with an underscore to indicate visibility Open
private $_serial = null;
- Exclude checks
Property name "$_manufacturer" should not be prefixed with an underscore to indicate visibility Open
private $_manufacturer = null;
- Exclude checks
Property name "$_name" should not be prefixed with an underscore to indicate visibility Open
private $_name = "";
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
- Exclude checks