Passed
Push — main ( 2d8ac8...d23358 )
by Daniel
04:33
created

GenreMapRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 28
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A save() 0 4 1
A findByAlbum() 0 5 1
A prototype() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Orm\Repository;
6
7
use Doctrine\ORM\EntityRepository;
8
use JetBrains\PhpStorm\Pure;
9
use Uxmp\Core\Orm\Model\AlbumInterface;
10
use Uxmp\Core\Orm\Model\GenreMap;
11
use Uxmp\Core\Orm\Model\GenreMapInterface;
12
13
/**
14
 * @extends EntityRepository<GenreMapInterface>
15
 *
16
 * @method null|GenreMapInterface findOneBy(mixed[] $criteria)
17
 */
18
final class GenreMapRepository extends EntityRepository implements GenreMapRepositoryInterface
19
{
20
    #[Pure]
21
    public function prototype(): GenreMapInterface
22
    {
23
        return new GenreMap();
24
    }
25
26
    public function save(GenreMapInterface $genreMap): void
27
    {
28
        $this->getEntityManager()->persist($genreMap);
29
        $this->getEntityManager()->flush();
30
    }
31
32
    public function delete(GenreMapInterface $genreMap): void
33
    {
34
        $this->getEntityManager()->remove($genreMap);
35
        $this->getEntityManager()->flush();
36
    }
37
38
    /**
39
     * @return iterable<GenreMapInterface>
40
     */
41
    public function findByAlbum(AlbumInterface $album): iterable
42
    {
43
        return $this->findBy([
44
            'mapped_item_type' => 'album',
45
            'mapped_item_id' => $album->getId(),
46
        ]);
47
    }
48
}
49