Lines
93.33%
14 / 15
Methods
50.00%
1 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| provide | 92.85% | 13 / 14 | 0.00% | 0 / 1 | 3.00 | ||
| 18 | final readonly class MeProvider implements ProviderInterface | |
| 19 | { | |
| 20 | public function __construct(private Security $security) | |
| 21 | { | |
| 22 | } | |
| 23 | ||
| 24 | public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?Me | |
| 25 | { | |
| 26 | $user = $this->security->getUser(); | |
| 27 | if (!$user instanceof User || null === $user->id) { | |
| 28 | return null; | |
| 29 | } | |
| 30 | ||
| 31 | return new Me( | |
| 32 | $user->id, | |
| 33 | $user->getIdentifier(), | |
| 34 | $user->getRole()->value, | |
| 35 | $user->getAgentName(), | |
| 36 | CustomMedals::fromArray($user->getCustomMedals()), | |
| 37 | $user->getVisibleParts(), | |
| 38 | $user->getVisibilityChosenAt() instanceof \DateTimeImmutable, | |
| 39 | $user->getAvatar(), | |
| 40 | Bannergress::fromStored($user->getBannergress()), | |
| 41 | ); | |
| 42 | } | |
| 43 | } |