isMembershipPaid()) { return; } $platformOffer = $value->getPlatformOffer(); if (null === $platformOffer) { $this->context->buildViolation($constraint->message) ->atPath('platformOffer') ->addViolation(); return; } if (null === $value->getStartAt()) { $this->context->buildViolation($constraint->message) ->atPath('startAt') ->addViolation(); } match ($platformOffer->getType()) { OfferType::YEARLY, OfferType::MONTHLY => $this->checkEndAt($value, $constraint), OfferType::ONESHOT => null, }; } private function checkEndAt(User $value, MembershipPaid $constraint): void { if (null === $value->getEndAt()) { $this->context->buildViolation($constraint->message) ->atPath('endAt') ->addViolation(); } } }