$occupied_by_slot Slot number => occupant. */ public static function from_occupied( array $occupied_by_slot ): self { return new self( $occupied_by_slot[1] ?? null, $occupied_by_slot[2] ?? null ); } /** * Bind the two named booking-form fields. * * @param BookingForm|null $form_1 First form field. * @param BookingForm|null $form_2 Second form field. */ public function __construct( private ?BookingForm $form_1 = null, private ?BookingForm $form_2 = null, ) {} /** * Occupy the first empty named field. * * @param BookingForm $form Incoming form. * @return int Slot number 1–2. * * @throws EditionLimitReached When form_1 and form_2 are both set. */ public function place( BookingForm $form ): int { if ( null === $this->form_1 ) { $this->form_1 = $form; return 1; } if ( null === $this->form_2 ) { $this->form_2 = $form; return 2; } throw new EditionLimitReached( EditionDimension::BookingForm, 2 ); } }