| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | final readonly class LocaleProviderService implements StepupLocaleProviderService |
||
| 26 | { |
||
| 27 | public function __construct(private TokenStorageInterface $tokenStorage) |
||
| 28 | { |
||
| 29 | } |
||
| 30 | |||
| 31 | public function determinePreferredLocale() |
||
| 32 | { |
||
| 33 | $token = $this->tokenStorage->getToken(); |
||
| 34 | |||
| 35 | if (!$token instanceof \Symfony\Component\Security\Core\Authentication\Token\TokenInterface) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** @var Identity $identity */ |
||
| 40 | $identity = $token->getUser(); |
||
| 41 | |||
| 42 | if (!$identity instanceof Identity) { |
||
| 43 | return; |
||
| 44 | } |
||
| 45 | |||
| 46 | return $identity->preferredLocale; |
||
| 47 | } |
||
| 48 | } |
||
| 49 |