Completed
Push — master ( 1a9043...984777 )
by Valentyn
08:31
created

WatchedMovieRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 16
ccs 0
cts 9
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAllWatchedMoviesByUserId() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Users\Repository;
5
6
use App\Users\Entity\User;
7
use App\Users\Entity\UserWatchedMovie;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Doctrine\ORM\Query;
10
use Symfony\Bridge\Doctrine\RegistryInterface;
11
12
/**
13
 * @method UserWatchedMovie|null find($id, $lockMode = null, $lockVersion = null)
14
 * @method UserWatchedMovie|null findOneBy(array $criteria, array $orderBy = null)
15
 * @method UserWatchedMovie[]    findAll()
16
 * @method UserWatchedMovie[]    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, UserWatchedMovie::class);
23
    }
24
25
    public function getAllWatchedMoviesByUserId(int $userId): Query
26
    {
27
        return $this->createQueryBuilder('wm')
28
            ->where('wm.user = :userId')
29
            ->setParameter('userId', $userId)
30
            ->addOrderBy('wm.id', 'DESC')
31
            ->getQuery();
32
    }
33
}
34