public/main/exercise/export/scorm/ScormAnswerMultipleChoice.php
Avoid unused local variables such as '$jstmpc'. Open
Open
$jstmpc = '';
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The method export uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$id = 1;
$jstmp = '';
$jstmpc = '';
foreach ($this->answer as $i => $answer) {
- 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
Variable "identifier_name" is not in valid camel caps format Open
Open
$identifier_name = 'question_'.$questionId.'_unique_answer';
- Exclude checks
Variable "identifier_name" is not in valid camel caps format Open
Open
<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/>
- Exclude checks
The variable $identifier_name is not named in camelCase. Open
Open
public function export()
{
$js = [];
$type = $this->getQuestionType();
$questionId = $this->questionJSId;
- 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 $identifier_name is not named in camelCase. Open
Open
public function export()
{
$js = [];
$type = $this->getQuestionType();
$questionId = $this->questionJSId;
- 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();
}
}