getAllWatchedMoviesByGuestSessionId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 14
cp 0
rs 9.7333
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\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