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

ActorRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 23
ccs 9
cts 12
cp 0.75
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findByTmdbId() 0 6 1
A findAllWithTranslations() 0 8 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\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