WatchedMovieRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAllWatchedMoviesByGuestSessionId() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Guests\Repository;
6
7
use App\Guests\Entity\GuestWatchedMovie;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Doctrine\ORM\Query;
10
use Symfony\Bridge\Doctrine\RegistryInterface;
11
12
/**
13
 * @method GuestWatchedMovie|null find($id, $lockMode = null, $lockVersion = null)
14
 * @method GuestWatchedMovie|null findOneBy(array $criteria, array $orderBy = null)
15
 * @method GuestWatchedMovie[]    findAll()
16
 * @method GuestWatchedMovie[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
17
 */
18
class WatchedMovieRepository extends ServiceEntityRepository
19
{
20
    public function __construct(RegistryInterface $registry)
21
    {
22
        parent::__construct($registry, GuestWatchedMovie::class);
23
    }
24
25
    public function getAllWatchedMoviesByGuestSessionId(int $guestSessionId): Query
26
    {
27
        return $this->createQueryBuilder('wm')
28
            ->leftJoin('wm.movie', 'm')
29
            ->addSelect('m')
30
            ->leftJoin('m.translations', 'mt')
31
            ->addSelect('mt')
32
            ->leftJoin('m.genres', 'mg')
33
            ->addSelect('mg')
34
            ->leftJoin('mg.translations', 'mgt')
35
            ->addSelect('mgt')
36
            ->where('wm.guestSession = :guestSessionId')
37
            ->setParameter('guestSessionId', $guestSessionId)
38
            ->addOrderBy('wm.id', 'DESC')
39
            ->getQuery();
40
    }
41
}
42