Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ResolvesAuthenticatedUser
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 securityUser
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Identity\Infrastructure\Http;
6
7use App\Identity\Infrastructure\Security\SecurityUser;
8use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
10/**
11 * For controllers sitting behind the stateless jwt firewall. The firewall
12 * guarantees an authenticated SecurityUser (an anonymous request is rejected
13 * with 401 before reaching the controller), so this never returns null — the
14 * assertion only narrows the type for static analysis.
15 *
16 * @mixin AbstractController
17 */
18trait ResolvesAuthenticatedUser
19{
20    private function securityUser(): SecurityUser
21    {
22        $user = $this->getUser();
23        assert($user instanceof SecurityUser);
24
25        return $user;
26    }
27}