assertBodyMeasurementsValid($participant); $this->assertTransportationSelected($participant); $this->assertPickupSelected($participant); } public function assertBodyMeasurementsValid(ParticipantDto $participant): void { if (0 === count($participant->rentals)) { return; } foreach (['height', 'shoeSize', 'weight'] as $property) { if (empty($participant->{$property})) { $this->context->buildViolation('Bitte angeben wegen Leihmaterial') ->atPath($property) ->addViolation() ; } } } public function assertTransportationSelected(ParticipantDto $participant): void { // no transportation services required for canceled participants if (true === $participant->isCanceled()) { return; } foreach (['transportationOutbound', 'transportationInbound'] as $property) { if (null === $participant->{$property}) { $this->context->buildViolation('Bitte angeben') ->atPath($property) ->addViolation() ; } } } public function assertPickupSelected(ParticipantDto $participant): void { // Check if either outbound or inbound transportation is bus $hasOutboundBus = null !== $participant->transportationOutbound && 'BUS' === $participant->transportationOutbound->subType; $hasInboundBus = null !== $participant->transportationInbound && 'BUS' === $participant->transportationInbound->subType; // Require pickup if at least one direction has bus transport if (($hasOutboundBus || $hasInboundBus) && null === $participant->pickup) { $this->context->buildViolation('Bitte auswählen') ->atPath('pickup') ->addViolation() ; } } }