Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
DoctrineUserIdentityRepository
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
3
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
 save
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 ofProviderSubject
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Identity\Infrastructure\Persistence\Doctrine;
6
7use App\Identity\Domain\UserIdentity;
8use App\Identity\Domain\UserIdentityRepository;
9use App\Identity\Domain\ValueObject\IdentityProvider;
10use Doctrine\ORM\EntityManagerInterface;
11
12final class DoctrineUserIdentityRepository implements UserIdentityRepository
13{
14    public function __construct(private readonly EntityManagerInterface $entityManager)
15    {
16    }
17
18    public function save(UserIdentity $identity): void
19    {
20        $this->entityManager->persist($identity);
21        $this->entityManager->flush();
22    }
23
24    public function ofProviderSubject(IdentityProvider $provider, string $subject): ?UserIdentity
25    {
26        return $this->entityManager->getRepository(UserIdentity::class)
27            ->findOneBy(['provider' => $provider, 'subject' => $subject]);
28    }
29}