The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (isset($link_object)) {
$this->link_object = $link_object;
}
}
- 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 method build_create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$select->addOption($link->get_type_name(), $linkType);
}
- 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 parameter $form_type is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $form_name is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The property $category_object is not named in camelCase. Open
class LinkForm extends FormValidator
{
const TYPE_CREATE = 1;
const TYPE_MOVE = 2;
/** @var Category */
- 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 parameter $category_object is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $link_object is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The property $link_object is not named in camelCase. Open
class LinkForm extends FormValidator
{
const TYPE_CREATE = 1;
const TYPE_MOVE = 2;
/** @var Category */
- 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
Variable "form_name" is not in valid camel caps format Open
parent::__construct($form_name, $method, $action);
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
$form_type,
- Exclude checks
Variable "link_object" is not in valid camel caps format Open
$link_object,
- Exclude checks
Method name "LinkForm::build_create" is not in camel caps format Open
protected function build_create()
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
} elseif (self::TYPE_MOVE == $form_type) {
- Exclude checks
Variable "category_object" is not in valid camel caps format Open
$this->category_object = $category_object;
- Exclude checks
Variable "category_object" is not in valid camel caps format Open
$this->category_object = $category_object;
- Exclude checks
Method name "LinkForm::build_move" is not in camel caps format Open
protected function build_move()
- Exclude checks
Variable "category_object" is not in valid camel caps format Open
$courseId = $this->category_object->getCourseId();
- Exclude checks
Variable "category_object" is not in valid camel caps format Open
if (isset($category_object)) {
- Exclude checks
Variable "link_object" is not in valid camel caps format Open
if (isset($link_object)) {
- Exclude checks
Variable "link_object" is not in valid camel caps format Open
$this->link_object = $link_object;
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
if (self::TYPE_CREATE == $form_type) {
- Exclude checks
Variable "link_object" is not in valid camel caps format Open
'"'.$this->link_object->get_name().'" '
- Exclude checks
Variable "link_object" is not in valid camel caps format Open
foreach ($this->link_object->get_target_categories() as $cat) {
- Exclude checks
Variable "category_object" is not in valid camel caps format Open
$category_object,
- Exclude checks
Variable "link_object" is not in valid camel caps format Open
$this->link_object = $link_object;
- Exclude checks
Variable "form_name" is not in valid camel caps format Open
$form_name,
- Exclude checks
The variable $link_object is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $form_type is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $link_object is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $form_type is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $category_object is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $category_object is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $form_name is not named in camelCase. Open
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method build_create is not named in camelCase. Open
protected function build_create()
{
$this->addHeader(get_lang('Add online activity'));
$select = $this->addSelect(
'select_link',
- 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() {
}
}
Source
The method build_move is not named in camelCase. Open
protected function build_move()
{
$renderer = &$this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$this->addElement(
- 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() {
}
}