Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
LinkStravaEndpoint
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 handle
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace Olz\Api\Endpoints;
4
5use Olz\Api\OlzTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @extends OlzTypedEndpoint<
10 *   array{
11 *     code: non-empty-string,
12 *   },
13 *   array{}
14 * >
15 */
16class LinkStravaEndpoint extends OlzTypedEndpoint {
17    protected function handle(mixed $input): mixed {
18        $user = $this->authUtils()->getCurrentUser();
19        if (!$user) {
20            throw new HttpError(403, "Kein Zugriff!");
21        }
22
23        $strava_link = $this->stravaUtils()->linkStrava($input['code']);
24        if ($strava_link === null) {
25            throw new HttpError(400, "Ungültige Anfrage!");
26        }
27
28        return [];
29    }
30}