lib/Ajde/Crud/Field/Icon.php
Method bootstrap2
has 142 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function bootstrap2()
{
return $this->convertBootstrapIcons([
'icon-glass',
'icon-music',
The method bootstrap2() has 145 lines of code. Current threshold is set to 100. Avoid really long methods. Open
Open
private function bootstrap2()
{
return $this->convertBootstrapIcons([
'icon-glass',
'icon-music',
- Exclude checks
The method getIconPackage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
return $this->iconPackage($this->defaultPackage);
}
- 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
The class Ajde_Crud_Field_Icon is not named in CamelCase. Open
Open
class Ajde_Crud_Field_Icon extends Ajde_Crud_Field
{
private $defaultPackage = 'bootstrap-2-default';
public function getIconPackage()
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The method _getHtmlAttributes is not named in camelCase. Open
Open
protected function _getHtmlAttributes()
{
$attributes = [];
$attributes['type'] = 'hidden';
$attributes['value'] = $this->getValue();
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}