TimeSpan
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class TimeSpan
{
/** @var DateTime */
private $startDate;
/** @var DateTime */
The method setStartDate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$endDate = clone $startDate;
$this->endDate = $endDate->add($this->dateInterval);
}
- 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 setEndDate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dateInterval = $this->dateInterval;
$dateInterval->invert = 1;
$startDate = clone $endDate;
$this->startDate = $startDate->add($dateInterval);
- 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 checkStartEndDateAndSetInterval uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new InvalidArgumentException(ErrorMessages::getStartDateMustBeBeforeEndDateMessage());
}
- 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 methods such as 'newDateIntervalAbsolute'. Open
private function newDateIntervalAbsolute($years, $months, $days)
{
$this->setDateInterval(
new DateInterval(
"P" .
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
TODO found Open
// TODO: make more intelligent rounding based on the start and end date
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
}
- Exclude checks