diff --git a/src/Doctrine/DBAL/Types/CronExpressionType.php b/src/Doctrine/DBAL/Types/CronExpressionType.php index ac15893..e385335 100644 --- a/src/Doctrine/DBAL/Types/CronExpressionType.php +++ b/src/Doctrine/DBAL/Types/CronExpressionType.php @@ -32,14 +32,10 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?CronExpr } if (!is_string($value)) { - if (class_exists(InvalidType::class)) { - throw InvalidType::new($value, CronExpression::class, ['string']); - } - /** * @psalm-suppress UndefinedMethod */ - throw ConversionException::conversionFailedInvalidType($value, CronExpression::class, ['string']); + throw class_exists(InvalidType::class) ? InvalidType::new($value, CronExpression::class, ['string']) : ConversionException::conversionFailedInvalidType($value, CronExpression::class, ['string']); } if ('' === $value) { @@ -49,14 +45,10 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?CronExpr try { return CronExpression::factory($value); } catch (\Throwable $e) { - if (class_exists(ValueNotConvertible::class)) { - throw ValueNotConvertible::new($value, CronExpression::class, null, $e); - } - /** * @psalm-suppress UndefinedMethod */ - throw ConversionException::conversionFailed($value, CronExpression::class, $e); + throw class_exists(ValueNotConvertible::class) ? ValueNotConvertible::new($value, CronExpression::class, null, $e) : ConversionException::conversionFailed($value, CronExpression::class, $e); } }