Completed
Push — master ( 4851fa...058e40 )
by Valentyn
04:07
created

GenreRepository::findAllWithTranslations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Genres\Repository;
6
7
use App\Genres\Entity\Genre;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Symfony\Bridge\Doctrine\RegistryInterface;
10
11
/**
12
 * @method Genre|null find($id, $lockMode = null, $lockVersion = null)
13
 * @method Genre|null findOneBy(array $criteria, array $orderBy = null)
14
 * @method Genre[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class GenreRepository extends ServiceEntityRepository
17
{
18 15
    public function __construct(RegistryInterface $registry)
19
    {
20 15
        parent::__construct($registry, Genre::class);
21 15
    }
22
23 1
    public function findByTmdbIds(array $ids)
24
    {
25 1
        return $this->createQueryBuilder('g')
26 1
            ->where('g.tmdbId IN (:ids)')
27 1
            ->setParameter('ids', $ids)
28 1
            ->getQuery()
29 1
            ->getResult();
30
    }
31
32 3
    public function findAllWithTranslations()
33
    {
34 3
        return $this->createQueryBuilder('g')
35 3
            ->leftJoin('g.translations', 'gt')
36 3
            ->addSelect('gt')
37 3
            ->orderBy('gt.name');
38
    }
39
}
40