Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateBookingEndpoint
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 configure
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 handle
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace Olz\Apps\Anmelden\Endpoints;
4
5use Olz\Api\OlzCreateEntityTypedEndpoint;
6use Olz\Entity\Anmelden\Booking;
7
8/**
9 * @phpstan-import-type OlzBookingId from BookingEndpointTrait
10 * @phpstan-import-type OlzBookingData from BookingEndpointTrait
11 *
12 * @extends OlzCreateEntityTypedEndpoint<OlzBookingId, OlzBookingData>
13 */
14class CreateBookingEndpoint extends OlzCreateEntityTypedEndpoint {
15    use BookingEndpointTrait;
16
17    public function configure(): void {
18        parent::configure();
19        $this->phpStanUtils->registerTypeImport(BookingEndpointTrait::class);
20    }
21
22    protected function handle(mixed $input): mixed {
23        $booking = new Booking();
24        $this->entityUtils()->createOlzEntity($booking, $input['meta']);
25        $this->updateEntityWithData($booking, $input['data']);
26
27        $this->entityManager()->persist($booking);
28        $this->entityManager()->flush();
29
30        $internal_booking_id = $booking->getId() ?? 0;
31        $external_booking_id = $this->idUtils()->toExternalId($internal_booking_id, 'Booking') ?: '-';
32
33        return [
34            'id' => $external_booking_id,
35        ];
36    }
37}