ActorRepository::findAllWithTranslations()   A
last analyzed

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\Actors\Repository;
6
7
use App\Actors\Entity\Actor;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Doctrine\ORM\QueryBuilder;
10
use Symfony\Bridge\Doctrine\RegistryInterface;
11
12
/**
13
 * @method Actor|null find($id, $lockMode = null, $lockVersion = null)
14
 * @method Actor|null findOneBy(array $criteria, array $orderBy = null)
15
 * @method Actor[]    findAll()
16
 * @method Actor[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
17
 */
18
class ActorRepository extends ServiceEntityRepository
19
{
20 5
    public function __construct(RegistryInterface $registry)
21
    {
22 5
        parent::__construct($registry, Actor::class);
23 5
    }
24
25
    public function findByTmdbId(int $tmdbId): ?Actor
26
    {
27
        return $this->findOneBy([
28
            'tmdb.id' => $tmdbId,
29
        ]);
30
    }
31
32 5
    public function findAllWithTranslations(): QueryBuilder
33
    {
34 5
        return $this->createQueryBuilder('a')
35 5
            ->leftJoin('a.translations', 'at')
36 5
            ->addSelect('at')
37 5
            ->orderBy('a.id', 'DESC');
38
    }
39
}
40