Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
GetKarteEndpoint
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Olz\Karten\Endpoints;
4
5use Olz\Api\OlzGetEntityTypedEndpoint;
6
7/**
8 * @phpstan-import-type OlzKarteId from KarteEndpointTrait
9 * @phpstan-import-type OlzKarteData from KarteEndpointTrait
10 *
11 * TODO: Those should not be necessary!
12 * @phpstan-import-type OlzKarteKind from KarteEndpointTrait
13 *
14 * @extends OlzGetEntityTypedEndpoint<OlzKarteId, OlzKarteData>
15 */
16class GetKarteEndpoint extends OlzGetEntityTypedEndpoint {
17    use KarteEndpointTrait;
18
19    public function configure(): void {
20        parent::configure();
21        $this->phpStanUtils->registerTypeImport(KarteEndpointTrait::class);
22    }
23
24    protected function handle(mixed $input): mixed {
25        $this->checkPermission('any');
26
27        $entity = $this->getEntityById($input['id']);
28
29        return [
30            'id' => $entity->getId() ?? 0,
31            'meta' => $entity->getMetaData(),
32            'data' => $this->getEntityData($entity),
33        ];
34    }
35}