Missing class import via use statement (line '46', column '54'). Open
$oItem = new scormItem(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '55', column '63'). Open
$this->metadata = new scormMetadata(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method get_ref uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return '';
}
- 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_name uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return '';
}
- 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 local variables such as '$dummy'. Open
foreach ($this->items as $id => $dummy) {
- 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 class scormOrganization is not named in CamelCase. Open
class scormOrganization
{
public $identifier = '';
public $structure = '';
public $title = '';
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Variable "tmp_children" is not in valid camel caps format Open
if (1 == $tmp_children->length && '' != $child->firstChild->nodeValue) {
- Exclude checks
Variable "tmp_children" is not in valid camel caps format Open
$tmp_children = $child->childNodes;
- Exclude checks
Method name "scormOrganization::get_flat_items_list" is not in camel caps format Open
public function get_flat_items_list()
- Exclude checks
Missing parameter name Open
* @param string Type of construction needed ('db' or 'manifest', default = 'manifest')
- Exclude checks
Missing parameter name Open
* @param mixed Depending on the type given, DB id for the lp_item or reference to the DOM element
- Exclude checks
Method name "scormOrganization::get_name" is not in camel caps format Open
public function get_name()
- Exclude checks
Method name "scormOrganization::get_ref" is not in camel caps format Open
public function get_ref()
- Exclude checks
Variable "abs_order" is not in valid camel caps format Open
$this->items[$id]->get_flat_list($list, $abs_order, $i, 0);
- Exclude checks
Method name "scormOrganization::set_name" is not in camel caps format Open
public function set_name($title)
- Exclude checks
Variable "abs_order" is not in valid camel caps format Open
$abs_order = 0;
- Exclude checks
Class name "scormOrganization" is not in camel caps format Open
class scormOrganization
- Exclude checks
The variable $abs_order is not named in camelCase. Open
public function get_flat_items_list()
{
$list = [];
$i = 1;
foreach ($this->items as $id => $dummy) {
- 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 $tmp_children is not named in camelCase. Open
public function __construct($type = 'manifest', &$element = null)
{
if (isset($element)) {
// Parsing using PHP5 DOMXML methods.
switch ($type) {
- 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 $abs_order is not named in camelCase. Open
public function get_flat_items_list()
{
$list = [];
$i = 1;
foreach ($this->items as $id => $dummy) {
- 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 $tmp_children is not named in camelCase. Open
public function __construct($type = 'manifest', &$element = null)
{
if (isset($element)) {
// Parsing using PHP5 DOMXML methods.
switch ($type) {
- 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_flat_items_list is not named in camelCase. Open
public function get_flat_items_list()
{
$list = [];
$i = 1;
foreach ($this->items as $id => $dummy) {
- 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 set_name is not named in camelCase. Open
public function set_name($title)
{
if (!empty($title)) {
$this->title = Database::escape_string($title);
}
- 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_ref is not named in camelCase. Open
public function get_ref()
{
if (!empty($this->identifier)) {
return Database::escape_string($this->identifier);
} else {
- 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_name is not named in camelCase. Open
public function get_name()
{
if (!empty($this->title)) {
return Database::escape_string($this->title);
} else {
- 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() {
}
}