The method build_user_info_form uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);
$this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);
}
- 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, $user, $form_name, $method = 'post', $action = null)
{
parent::__construct($form_name, $method, $action);
$this->form_type = $form_type;
if (isset($user)) {
- 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, $user, $form_name, $method = 'post', $action = null)
{
parent::__construct($form_name, $method, $action);
$this->form_type = $form_type;
if (isset($user)) {
- 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
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
} elseif (self::TYPE_SIMPLE_SEARCH == $this->form_type) {
- Exclude checks
Missing function doc comment Open
public function setDefaults($defaultValues = [], $filter = null)
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
if (self::TYPE_USER_INFO == $this->form_type) {
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
'<a href="mailto:'.$this->user_info['email'].'">'.$this->user_info['email'].'</a>'
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'ofcode', get_lang('Code'), $this->user_info['official_code']);
- Exclude checks
Variable "form_name" is not in valid camel caps format Open
parent::__construct($form_name, $method, $action);
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
$this->form_type = $form_type;
- Exclude checks
Missing function doc comment Open
public function display()
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
$this->form_type = $form_type;
- Exclude checks
Method name "UserForm::build_user_info_form" is not in camel caps format Open
protected function build_user_info_form()
- Exclude checks
Variable "form_name" is not in valid camel caps format Open
public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
- Exclude checks
Method name "UserForm::build_simple_search" is not in camel caps format Open
protected function build_simple_search()
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
'<a href="mailto:'.$this->user_info['email'].'">'.$this->user_info['email'].'</a>'
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->user_info = $user;
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'uname', get_lang('Username'), $this->user_info['username']);
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);
- Exclude checks
The variable $form_type is not named in camelCase. Open
public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
{
parent::__construct($form_name, $method, $action);
$this->form_type = $form_type;
if (isset($user)) {
- 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, $user, $form_name, $method = 'post', $action = null)
{
parent::__construct($form_name, $method, $action);
$this->form_type = $form_type;
if (isset($user)) {
- 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_simple_search is not named in camelCase. Open
protected function build_simple_search()
{
if (isset($_GET['search']) && (!empty($_GET['search']))) {
$this->setDefaults([
'keyword' => Security::remove_XSS($_GET['search']),
- 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_user_info_form is not named in camelCase. Open
protected function build_user_info_form()
{
if (api_is_western_name_order()) {
$this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);
$this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);
- 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() {
}
}