Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
GetSnippetEndpoint
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
6
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 / 7
0.00% covered (danger)
0.00%
0 / 1
2
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}