The method get_request_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$sql = "SELECT
code AS col0,
title AS col1,
category_code AS col2,
- 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 get_request_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$course_request[4] = api_get_local_time($course_request[4]);
}
- 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 $number_of_items is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 "this_section" is not in valid camel caps format Open
$this_section = SECTION_PLATFORM_ADMIN;
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = isset($_GET['is_error_message']) ? !empty($_GET['is_error_message']) : '';
- Exclude checks
Variable "course_validation_feature" is not in valid camel caps format Open
if ($course_validation_feature) {
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has been accepted. A new course %s has been created.'), $course_request_code, $course_code);
- Exclude checks
Variable "reject_course_request" is not in valid camel caps format Open
} elseif (!empty($reject_course_request)) {
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('Additional information about the course request %s has been asked.'), $course_request_code);
- Exclude checks
Variable "course_request_id" is not in valid camel caps format Open
$success &= CourseRequestManager::delete_course_request($course_request_id);
- Exclude checks
Variable "course_request" is not in valid camel caps format Open
while ($course_request = Database::fetch_row($res)) {
- Exclude checks
Multi-line function call not indented correctly; expected 0 spaces but found 4 Open
).
- Exclude checks
Variable "delete_course_request" is not in valid camel caps format Open
$delete_course_request = isset($_GET['delete_course_request']) ? (int) ($_GET['delete_course_request']) : '';
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = true;
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = true;
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = false;
- Exclude checks
Variable "course_request" is not in valid camel caps format Open
$course_requests[] = $course_request;
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
$tool_name = get_lang('Review incoming course requests');
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
$course_id = CourseRequestManager::accept_course_request($accept_course_request);
- Exclude checks
Variable "course_request_id" is not in valid camel caps format Open
foreach ($_POST['course_request'] as $index => $course_request_id) {
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
$number_of_items = (int) $number_of_items;
- Exclude checks
Variable "course_requests" is not in valid camel caps format Open
$course_requests[] = $course_request;
- Exclude checks
Variable "course_validation_feature" is not in valid camel caps format Open
if (!$course_validation_feature) {
- Exclude checks
Variable "request_info" is not in valid camel caps format Open
$request_info = isset($_GET['request_info']) ? (int) ($_GET['request_info']) : '';
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = false;
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($reject_course_request);
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has not been rejected due to internal error.'), $course_request_code);
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($request_info);
- Exclude checks
Variable "course_requests" is not in valid camel caps format Open
$course_requests = [];
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
if ($is_error_message) {
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = true;
- Exclude checks
Variable "delete_course_request" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
- Exclude checks
Variable "link_to_setting" is not in valid camel caps format Open
sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('Courses validation'))
- Exclude checks
Variable "link_to_setting" is not in valid camel caps format Open
$link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
- Exclude checks
Consider putting global function "modify_filter" in a static class Open
function modify_filter($id)
- Exclude checks
Variable "course_request_table" is not in valid camel caps format Open
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
StateIcon::COMPLETE,
- Exclude checks
Variable "course_request_table" is not in valid camel caps format Open
FROM $course_request_table
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
'ch-tool-icon',
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
ICON_SIZE_SMALL,
- Exclude checks
Variable "accept_course_request" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);
- Exclude checks
Variable "reject_course_request" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($reject_course_request);
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has been deleted.'), $course_request_code);
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
function get_request_data($from, $number_of_items, $column, $direction)
- Exclude checks
Variable "course_request" is not in valid camel caps format Open
$course_request[5] = api_get_local_time($course_request[5]);
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
get_lang('Rejected course requests')
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has not been accepted due to internal error.'), $course_request_code);
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = false;
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = true;
- Exclude checks
Variable "tool_name" is not in valid camel caps format Open
Display::display_header($tool_name);
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
get_lang('Accepted course requests')
- Exclude checks
Variable "course_validation_feature" is not in valid camel caps format Open
$course_validation_feature = 'true' == api_get_setting('course_validation');
- Exclude checks
Variable "accept_course_request" is not in valid camel caps format Open
$accept_course_request = isset($_GET['accept_course_request']) ? (int) ($_GET['accept_course_request']) : '';
- Exclude checks
Variable "accept_course_request" is not in valid camel caps format Open
$course_id = CourseRequestManager::accept_course_request($accept_course_request);
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has been rejected.'), $course_request_code);
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
$number_of_items = (int) $number_of_items;
- Exclude checks
Variable "course_requests" is not in valid camel caps format Open
return $course_requests;
- Exclude checks
Consider putting global function "email_filter" in a static class Open
function email_filter($teacher)
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
'ch-tool-icon',
- Exclude checks
Variable "delete_course_request" is not in valid camel caps format Open
} elseif (!empty($delete_course_request)) {
- Exclude checks
Multi-line function call not indented correctly; expected 0 spaces but found 4 Open
).
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);
- Exclude checks
Variable "course_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has been accepted. A new course %s has been created.'), $course_request_code, $course_code);
- Exclude checks
Variable "request_info" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($request_info);
- Exclude checks
Variable "delete_course_request" is not in valid camel caps format Open
$result = CourseRequestManager::delete_course_request($delete_course_request);
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = true;
- Exclude checks
Consider putting global function "get_request_data" in a static class Open
function get_request_data($from, $number_of_items, $column, $direction)
- Exclude checks
Variable "course_request" is not in valid camel caps format Open
$course_request[5] = api_get_local_time($course_request[5]);
- Exclude checks
Variable "course_request" is not in valid camel caps format Open
$course_request[4] = api_get_local_time($course_request[4]);
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
null,
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
$course_code = CourseManager::get_course_code_from_course_id($course_id);
- Exclude checks
Variable "request_info" is not in valid camel caps format Open
$result = CourseRequestManager::ask_for_additional_info($request_info);
- Exclude checks
Consider putting global function "get_number_of_requests" in a static class Open
function get_number_of_requests()
- Exclude checks
Variable "course_request_table" is not in valid camel caps format Open
FROM $course_request_table
- Exclude checks
Variable "accept_course_request" is not in valid camel caps format Open
if (!empty($accept_course_request)) {
- Exclude checks
Variable "request_info" is not in valid camel caps format Open
} elseif (!empty($request_info)) {
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('The course request %s has not been deleted due to internal error.'), $course_request_code);
- Exclude checks
Variable "course_request" is not in valid camel caps format Open
$course_request[4] = api_get_local_time($course_request[4]);
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
StateIcon::INCOMPLETE,
- Exclude checks
Variable "reject_course_request" is not in valid camel caps format Open
$reject_course_request = isset($_GET['reject_course_request']) ? (int) ($_GET['reject_course_request']) : '';
- Exclude checks
Variable "reject_course_request" is not in valid camel caps format Open
$result = CourseRequestManager::reject_course_request($reject_course_request);
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
$sql .= " LIMIT $from,$number_of_items";
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
if ($course_id) {
- Exclude checks
Variable "course_code" is not in valid camel caps format Open
$course_code = CourseManager::get_course_code_from_course_id($course_id);
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$message = sprintf(get_lang('Additional information about the course request %s has not been asked due to internal error.'), $course_request_code);
- Exclude checks
Variable "course_request_code" is not in valid camel caps format Open
$course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = false;
- Exclude checks
Variable "course_requests" is not in valid camel caps format Open
$course_requests = $_POST['course_request'];
- Exclude checks
Variable "is_error_message" is not in valid camel caps format Open
$is_error_message = !$success;
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
null,
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
ICON_SIZE_SMALL,
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
ICON_SIZE_SMALL,
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
get_lang('Rejected course requests')
- Exclude checks
Multi-line function call not indented correctly; expected 0 spaces but found 4 Open
).
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
StateIcon::COMPLETE,
- Exclude checks
Multi-line function call not indented correctly; expected 0 spaces but found 4 Open
).
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
null,
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
get_lang('Accepted course requests')
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
StateIcon::INCOMPLETE,
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
'ch-tool-icon',
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
'ch-tool-icon',
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
ICON_SIZE_SMALL,
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
null,
- Exclude checks
The variable $course_requests is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $number_of_items is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request_table is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request_table is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_requests is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $number_of_items is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request_table is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_requests is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $number_of_items is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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 $course_request is not named in camelCase. Open
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
- 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();
}
}