Student
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Student {
// Defines for Internship Inventory student Data
const MAIN_CAMPUS = 'main_campus';
const DISTANCE_ED = 'distance_ed';
- Create a ticketCreate a ticket
The class Student has 16 fields. Consider redesigning Student to keep the number of fields under 15. Open
class Student {
// Defines for Internship Inventory student Data
const MAIN_CAMPUS = 'main_campus';
const DISTANCE_ED = 'distance_ed';
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Avoid using undefined variables such as '$level' which will lead to PHP notices. Open
if ($level == self::UNDERGRAD) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The method isCreditHourLimited uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$limit = $term->getGradOverloadHours();
}
- Read upRead up
- Create a ticketCreate a ticket
- 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 isCreditHourLimited uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return false;
}
- Read upRead up
- Create a ticketCreate a ticket
- 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 '$level'. Open
if ($level == self::UNDERGRAD) {
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid unused local variables such as '$semester'. Open
$semester = $term->getSemesterType();
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid unused local variables such as '$code'. Open
$code = $this->getLevel();
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid unused private fields such as '$holds'. Open
private $holds;
- Read upRead up
- Create a ticketCreate a ticket
- 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
Variable $level
is undeclared (Did you mean $this->level) Open
if ($level == self::UNDERGRAD) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared constant \Intern\Student::UNDERGRAD
Open
if ($level == self::UNDERGRAD) {
- Create a ticketCreate a ticket
- Exclude checks
Doc-block of $major
in addMajor
contains phpdoc param type \stdClass
which is incompatible with the param type \Intern\AcademicMajor
declared in the signature Open
* @param \stdClass $major A major object
- Create a ticketCreate a ticket
- Exclude checks