From 876ebca210d808c7e09af909efcc5ab6d77f6e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 30 Aug 2023 14:33:53 +0200 Subject: [PATCH] Birthdate validator: remove unused comparison --- .../Constraints/Person/BirthdateValidator.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php index 35e67dc62..c0d9105ad 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php @@ -31,8 +31,8 @@ class BirthdateValidator extends ConstraintValidator private string $below_interval = 'P150Y'; public function __construct( - private ParameterBagInterface $parameterBag, - private ClockInterface $clock + private readonly ParameterBagInterface $parameterBag, + private readonly ClockInterface $clock ) { $this->interval_spec = $this->parameterBag->get('chill_person')['validation']['birthdate_not_after']; } @@ -71,13 +71,9 @@ class BirthdateValidator extends ConstraintValidator private function getLimitDate(): DateTime { - if (null !== $this->interval_spec) { - $interval = new DateInterval($this->interval_spec); + $interval = new DateInterval($this->interval_spec); - return DateTime::createFromImmutable($this->clock->now()->sub($interval)); - } - - return DateTime::createFromImmutable($this->clock->now()); + return DateTime::createFromImmutable($this->clock->now()->sub($interval)); } private function getBelowLimitDate(): DateTime