Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CreateTerminEndpoint
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Olz\Termine\Endpoints;
4
5use Olz\Api\OlzCreateEntityTypedEndpoint;
6use Olz\Entity\Termine\Termin;
7
8/**
9 * @phpstan-import-type OlzTerminId from TerminEndpointTrait
10 * @phpstan-import-type OlzTerminData from TerminEndpointTrait
11 *
12 * @extends OlzCreateEntityTypedEndpoint<OlzTerminId, OlzTerminData>
13 */
14class CreateTerminEndpoint extends OlzCreateEntityTypedEndpoint {
15    use TerminEndpointTrait;
16
17    public function configure(): void {
18        parent::configure();
19        $this->configureTerminEndpointTrait();
20        $this->phpStanUtils->registerTypeImport(TerminEndpointTrait::class);
21    }
22
23    protected function handle(mixed $input): mixed {
24        $this->checkPermission('termine');
25
26        $entity = new Termin();
27        $this->entityUtils()->createOlzEntity($entity, $input['meta']);
28        $this->updateEntityWithData($entity, $input['data']);
29
30        $this->entityManager()->persist($entity);
31        $this->entityManager()->flush();
32        $this->persistUploads($entity, $input['data']);
33
34        return [
35            'id' => $entity->getId() ?? 0,
36        ];
37    }
38}