Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
9 / 9 |
|
85.71% |
6 / 7 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| UserProvider | |
100.00% |
11 / 11 |
|
100.00% |
9 / 9 |
|
85.71% |
6 / 7 |
|
100.00% |
4 / 4 |
6.10 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| loadUserByIdentifier | |
100.00% |
8 / 8 |
|
100.00% |
6 / 6 |
|
75.00% |
3 / 4 |
|
100.00% |
1 / 1 |
3.14 | |||
| refreshUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| supportsClass | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Auth\Infrastructure\Security; |
| 4 | |
| 5 | use App\Auth\Domain\Port\Driven\IdentityRepository; |
| 6 | use App\Auth\Infrastructure\Security\User\AuthenticatedUser; |
| 7 | use App\Shared\Domain\Exception\InvalidEntityIdException; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use Override; |
| 10 | use Psr\Log\LoggerInterface; |
| 11 | use Symfony\Component\Security\Core\Exception\UserNotFoundException; |
| 12 | use Symfony\Component\Security\Core\User\UserInterface; |
| 13 | use Symfony\Component\Security\Core\User\UserProviderInterface; |
| 14 | |
| 15 | /** |
| 16 | * @author Wilhelm Zwertvaegher |
| 17 | * @implements UserProviderInterface<UserInterface> |
| 18 | */ |
| 19 | readonly class UserProvider implements UserProviderInterface |
| 20 | { |
| 21 | public function __construct(private IdentityRepository $repository, private readonly LoggerInterface $logger) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | #[Override] |
| 26 | public function loadUserByIdentifier(string $identifier): UserInterface |
| 27 | { |
| 28 | try { |
| 29 | $identity = $this->repository->findById(EntityId::fromString($identifier)); |
| 30 | } catch (InvalidEntityIdException $e) { |
| 31 | $identity = $this->repository->findByIdentifier($identifier); |
| 32 | } |
| 33 | |
| 34 | if (!$identity) { |
| 35 | $this->logger->info("Identity '$identifier' not found."); |
| 36 | throw new UserNotFoundException("Identity '$identifier' not found."); |
| 37 | } |
| 38 | $this->logger->info("Identity for '$identifier' found."); |
| 39 | return new AuthenticatedUser($identity); |
| 40 | } |
| 41 | |
| 42 | #[Override] |
| 43 | public function refreshUser(UserInterface $user): UserInterface |
| 44 | { |
| 45 | return $user; // JWT → stateless |
| 46 | } |
| 47 | |
| 48 | #[Override] |
| 49 | public function supportsClass(string $class): bool |
| 50 | { |
| 51 | return $class === AuthenticatedUser::class; |
| 52 | } |
| 53 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 21 | public function __construct(private IdentityRepository $repository, private readonly LoggerInterface $logger) |
| 22 | { |
| 23 | } |
| 26 | public function loadUserByIdentifier(string $identifier): UserInterface |
| 27 | { |
| 28 | try { |
| 29 | $identity = $this->repository->findById(EntityId::fromString($identifier)); |
| 34 | if (!$identity) { |
| 35 | $this->logger->info("Identity '$identifier' not found."); |
| 36 | throw new UserNotFoundException("Identity '$identifier' not found."); |
| 26 | public function loadUserByIdentifier(string $identifier): UserInterface |
| 27 | { |
| 28 | try { |
| 29 | $identity = $this->repository->findById(EntityId::fromString($identifier)); |
| 34 | if (!$identity) { |
| 38 | $this->logger->info("Identity for '$identifier' found."); |
| 39 | return new AuthenticatedUser($identity); |
| 40 | } |
| 30 | } catch (InvalidEntityIdException $e) { |
| 31 | $identity = $this->repository->findByIdentifier($identifier); |
| 32 | } |
| 33 | |
| 34 | if (!$identity) { |
| 34 | if (!$identity) { |
| 35 | $this->logger->info("Identity '$identifier' not found."); |
| 36 | throw new UserNotFoundException("Identity '$identifier' not found."); |
| 30 | } catch (InvalidEntityIdException $e) { |
| 31 | $identity = $this->repository->findByIdentifier($identifier); |
| 32 | } |
| 33 | |
| 34 | if (!$identity) { |
| 34 | if (!$identity) { |
| 38 | $this->logger->info("Identity for '$identifier' found."); |
| 39 | return new AuthenticatedUser($identity); |
| 40 | } |
| 43 | public function refreshUser(UserInterface $user): UserInterface |
| 44 | { |
| 45 | return $user; // JWT → stateless |
| 46 | } |
| 49 | public function supportsClass(string $class): bool |
| 50 | { |
| 51 | return $class === AuthenticatedUser::class; |
| 52 | } |
| 3 | namespace App\Auth\Infrastructure\Security; |
| 4 | |
| 5 | use App\Auth\Domain\Port\Driven\IdentityRepository; |
| 6 | use App\Auth\Infrastructure\Security\User\AuthenticatedUser; |
| 7 | use App\Shared\Domain\Exception\InvalidEntityIdException; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use Override; |
| 10 | use Psr\Log\LoggerInterface; |
| 11 | use Symfony\Component\Security\Core\Exception\UserNotFoundException; |
| 12 | use Symfony\Component\Security\Core\User\UserInterface; |
| 13 | use Symfony\Component\Security\Core\User\UserProviderInterface; |
| 14 | |
| 15 | /** |
| 16 | * @author Wilhelm Zwertvaegher |
| 17 | * @implements UserProviderInterface<UserInterface> |
| 18 | */ |
| 19 | readonly class UserProvider implements UserProviderInterface |
| 20 | { |
| 21 | public function __construct(private IdentityRepository $repository, private readonly LoggerInterface $logger) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | #[Override] |
| 26 | public function loadUserByIdentifier(string $identifier): UserInterface |
| 27 | { |
| 28 | try { |
| 29 | $identity = $this->repository->findById(EntityId::fromString($identifier)); |
| 30 | } catch (InvalidEntityIdException $e) { |
| 31 | $identity = $this->repository->findByIdentifier($identifier); |
| 32 | } |
| 33 | |
| 34 | if (!$identity) { |
| 35 | $this->logger->info("Identity '$identifier' not found."); |
| 36 | throw new UserNotFoundException("Identity '$identifier' not found."); |
| 37 | } |
| 38 | $this->logger->info("Identity for '$identifier' found."); |
| 39 | return new AuthenticatedUser($identity); |
| 40 | } |
| 41 | |
| 42 | #[Override] |
| 43 | public function refreshUser(UserInterface $user): UserInterface |
| 44 | { |
| 45 | return $user; // JWT → stateless |
| 46 | } |
| 47 | |
| 48 | #[Override] |
| 49 | public function supportsClass(string $class): bool |
| 50 | { |
| 51 | return $class === AuthenticatedUser::class; |
| 52 | } |