Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ConnectedUser
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
6
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __get
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 __isset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace AppDemo\Shared\Presentation\Twig;
11
12use AppDemo\Shared\Domain\Interface\SessionServiceInterface;
13
14final readonly class ConnectedUser
15{
16    public function __construct(private SessionServiceInterface $sessionService) {}
17
18    public function __get(string $name): mixed
19    {
20        return match ($name) {
21            'is_authenticated' => $this->sessionService->isUserAuthenticated(),
22            'email' => $this->sessionService->getUserEmail()?->getValue(),
23            default => null,
24        };
25    }
26
27    public function __isset(string $name): bool
28    {
29        return in_array($name, ['is_authenticated', 'email'], true);
30    }
31}