ActorRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 22
ccs 8
cts 11
cp 0.7272
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 7 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