jaroslavtyc/doctrineum-date-interval

View on GitHub
Doctrineum/DateInterval/DateInterval.php

Summary

Maintainability
A
45 mins
Test Coverage

Showing 2 of 2 total issues

Function intervalToSeconds has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

public static function intervalToSeconds(\DateInterval $interval): string
{
$seconds = $interval->s;
if ($interval->i > 0) {
$seconds += $interval->i * self::SECONDS_MINUTE;
Severity: Minor
Found in Doctrineum/DateInterval/DateInterval.php - About 45 mins to fix

The method intervalToSeconds uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

} else { // integer overflow
// fallback with Boston Math calculation (result is in string)
$seconds = bcadd($seconds, bcmul($interval->y, self::SECONDS_YEAR));
}
Category
Status