jaroslavtyc/doctrineum-date-interval

View on GitHub

Showing 9 of 9 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));
}

Avoid using static access to class '\Doctrine\DBAL\Types\ConversionException' in method 'convertToPHPValue'.
Open

throw ConversionException::conversionFailedFormat(
$value,
$this->getName(),
'^\\d+$'
);

Avoid using static access to class '\Doctrineum\DateInterval\DateInterval' in method 'convertToPHPValue'.
Open

return DateInterval::fromSeconds($value);

Avoid unused parameters such as '$sqlWalker'.
Open

public function getSql(SqlWalker $sqlWalker): string

Avoid using static access to class '\Doctrineum\DateInterval\DateInterval' in method 'convertToDatabaseValue'.
Open

: DateInterval::intervalToSeconds($value);

Avoid using static access to class '\Doctrineum\DateInterval\DateInterval' in method 'getSql'.
Open

return DateInterval::intervalToSeconds(new DateInterval($this->intervalSpec->value));

Avoid unused parameters such as '$platform'.
Open

public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string

Avoid unused parameters such as '$platform'.
Open

public function convertToPHPValue($value, AbstractPlatform $platform): ?DateInterval
Severity
Category
Status
Source
Language