Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
GetAppStatisticsCredentialsEndpoint
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 handle
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Olz\Apps\Statistics\Endpoints;
4
5use Olz\Api\OlzTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @extends OlzTypedEndpoint<
10 *   array{},
11 *   array{username: string, password: string}
12 * >
13 */
14class GetAppStatisticsCredentialsEndpoint extends OlzTypedEndpoint {
15    protected function handle(mixed $input): mixed {
16        if (!$this->authUtils()->hasPermission('all')) {
17            throw new HttpError(403, "Kein Zugriff!");
18        }
19
20        $user = $this->authUtils()->getCurrentUser();
21        $this->log()->info("Statistics credentials access by {$user?->getUsername()}.");
22
23        return [
24            'username' => $this->envUtils()->getAppStatisticsUsername(),
25            'password' => $this->envUtils()->getAppStatisticsPassword(),
26        ];
27    }
28}