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