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
GetSnippetEndpoint
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\Snippets\Endpoints;
4
5use Olz\Api\OlzGetEntityTypedEndpoint;
6
7/**
8 * @phpstan-import-type OlzSnippetId from SnippetEndpointTrait
9 * @phpstan-import-type OlzSnippetData from SnippetEndpointTrait
10 *
11 * @extends OlzGetEntityTypedEndpoint<OlzSnippetId, OlzSnippetData>
12 */
13class GetSnippetEndpoint extends OlzGetEntityTypedEndpoint {
14    use SnippetEndpointTrait;
15
16    public function configure(): void {
17        parent::configure();
18        $this->phpStanUtils->registerTypeImport(SnippetEndpointTrait::class);
19    }
20
21    protected function handle(mixed $input): mixed {
22        $this->checkPermission('any');
23
24        $entity = $this->getEntityById($input['id']);
25
26        return [
27            'id' => $entity->getId() ?? 0,
28            'meta' => $entity->getMetaData(),
29            'data' => $this->getEntityData($entity),
30        ];
31    }
32}