Completed
Push — master ( b4d909...e3c084 )
by Valentyn
03:37
created

ActorRepository::findByTmdbId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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\Query;
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 2
    public function __construct(RegistryInterface $registry)
21
    {
22 2
        parent::__construct($registry, Actor::class);
23 2
    }
24
25
    public function findByTmdbId(int $tmdbId): ?Actor
26
    {
27
        return $this->findOneBy([
28
            'tmdb.id' => $tmdbId,
29
        ]);
30
    }
31
32 2
    public function findAllWithTranslations(): Query
33
    {
34 2
        return $this->createQueryBuilder('a')
35 2
            ->leftJoin('a.translations', 'at')
36 2
            ->addSelect('at')
37 2
            ->orderBy('a.id', 'DESC')
38 2
            ->getQuery();
39
    }
40
}
41