Passed
Push — main ( 3af14e...84a818 )
by Daniel
04:35
created

UserSettingsRetrieveApplication::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 12
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Api\User;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Uxmp\Core\Api\AbstractApiApplication;
10
use Uxmp\Core\Component\Session\SessionValidatorMiddleware;
11
use Uxmp\Core\Orm\Model\UserInterface;
12
13
/**
14
 * Delivers the user settings
15
 */
16
final class UserSettingsRetrieveApplication extends AbstractApiApplication
17
{
18 1
    protected function run(
19
        ServerRequestInterface $request,
20
        ResponseInterface $response,
21
        array $args
22
    ): ResponseInterface {
23
        /** @var UserInterface $user */
24 1
        $user = $request->getAttribute(SessionValidatorMiddleware::USER);
25
26 1
        return $this->asJson(
27 1
            $response,
28
            [
29 1
                'language' => $user->getLanguage(),
30
            ]
31
        );
32
    }
33
}
34