| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class AuthorRepository implements AuthorRepositoryInterface |
||
| 14 | { |
||
| 15 | use OrmRepositoryTrait; |
||
| 16 | |||
| 17 | public function __construct(EntityManagerInterface $em, string $className = Author::class) |
||
| 18 | { |
||
| 19 | $this->em = $em; |
||
| 20 | $this->className = $className; |
||
| 21 | } |
||
| 22 | |||
| 23 | public function byId(AuthorId $id): ?Author |
||
| 24 | { |
||
| 25 | /** @var Author $author */ |
||
| 26 | $author = $this->em->find($this->className, $id); |
||
| 27 | |||
| 28 | return $author; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function add(Author $author): void |
||
| 32 | { |
||
| 33 | $this->em->persist($author); |
||
| 34 | $this->em->flush($author); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function update(Author $author): void |
||
| 38 | { |
||
| 39 | $this->em->persist($author); |
||
| 40 | $this->em->flush($author); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function all(): array |
||
| 44 | { |
||
| 45 | return $this->createQueryBuilder('a')->getQuery()->getResult(); |
||
| 46 | } |
||
| 48 |