The method getContent uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$class_tr = 'row_even';
}
- 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 getContent uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
}
- 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
Avoid unused private fields such as '$courses'. Open
private $courses;
- Read upRead up
- Exclude checks
UnusedPrivateField
Since: 0.2
Detects when a private field is declared and/or assigned a value, but not used.
Example
class Something
{
private static $FOO = 2; // Unused
private $i = 5; // Unused
private $j = 6;
public function addOne()
{
return $this->j++;
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield
The property $user_id is not named in camelCase. Open
class BlockGlobalInfo extends Block
{
private $user_id;
private $courses;
private $permission = [];
- 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 $user_id is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $user_id is not named in camelCase. Open
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->path = 'block_global_info';
}
- 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
Method name "BlockGlobalInfo::is_block_visible_for_user" is not in camel caps format Open
public function is_block_visible_for_user($user_id)
- Exclude checks
Variable "class_tr" is not in valid camel caps format Open
$class_tr = 'row_odd';
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
public function is_block_visible_for_user($user_id)
- Exclude checks
Variable "global_data" is not in valid camel caps format Open
foreach ($global_data as $data) {
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table .= '<tr class="'.$class_tr.'">';
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
return $data_table;
- Exclude checks
Variable "is_block_visible_for_user" is not in valid camel caps format Open
$is_block_visible_for_user = false;
- Exclude checks
Variable "is_block_visible_for_user" is not in valid camel caps format Open
return $is_block_visible_for_user;
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table .= '</table>';
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
$this->user_id = $user_id;
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$user_status = $user_info['status'];
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
$this->user_id = $user_id;
- Exclude checks
Variable "class_tr" is not in valid camel caps format Open
$data_table .= '<tr class="'.$class_tr.'">';
- Exclude checks
Method name "BlockGlobalInfo::get_global_information_data" is not in camel caps format Open
public function get_global_information_data()
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
public function __construct($user_id)
- Exclude checks
Variable "global_data" is not in valid camel caps format Open
if (!empty($global_data)) {
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table = '<table class="table table-bordered">';
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table .= '</tr>';
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table .= '<td align="right">'.$cell.'</td>';
- Exclude checks
Method name "BlockGlobalInfo::get_block" is not in camel caps format Open
public function get_block()
- Exclude checks
Variable "global_data" is not in valid camel caps format Open
$global_data = $this->get_global_information_data();
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
- Exclude checks
Variable "is_block_visible_for_user" is not in valid camel caps format Open
$is_block_visible_for_user = true;
- Exclude checks
Variable "user_info" is not in valid camel caps format Open
$user_info = api_get_user_info($user_id);
- Exclude checks
Variable "user_status" is not in valid camel caps format Open
$user_status = $user_info['status'];
- Exclude checks
Variable "user_id" is not in valid camel caps format Open
$user_info = api_get_user_info($user_id);
- Exclude checks
Variable "user_status" is not in valid camel caps format Open
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
- Exclude checks
Variable "class_tr" is not in valid camel caps format Open
$class_tr = 'row_even';
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table = null;
- Exclude checks
Variable "data_table" is not in valid camel caps format Open
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
- Exclude checks
The variable $class_tr is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $is_block_visible_for_user is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $user_info is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $user_id is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $user_status is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $global_data is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $class_tr is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $user_info is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $user_id is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $class_tr is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $is_block_visible_for_user is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $user_status is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $global_data is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $is_block_visible_for_user is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 $global_data is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $user_id is not named in camelCase. Open
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->path = 'block_global_info';
}
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 $data_table is not named in camelCase. Open
public function getContent()
{
$global_data = $this->get_global_information_data();
$data_table = null;
if (!empty($global_data)) {
- 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 get_global_information_data is not named in camelCase. Open
public function get_global_information_data()
{
// Two-dimensional array with data about the system
$path = api_get_path(WEB_CODE_PATH);
// Check total number of users
- 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 is_block_visible_for_user is not named in camelCase. Open
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
- 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 get_block is not named in camelCase. Open
public function get_block()
{
$column = 2;
$data = [];
$html = $this->getBlockCard(
- 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() {
}
}