Completed
Push — master ( 49afcb...98eb90 )
by Valentyn
05:04
created

InterestedMovieRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Users\Repository;
6
7
use App\Movies\Entity\Movie;
8
use App\Users\Entity\UserInterestedMovie;
9
use App\Users\Entity\UserWatchedMovie;
10
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
11
use Symfony\Bridge\Doctrine\RegistryInterface;
12
13
/**
14
 * @method UserInterestedMovie|null find($id, $lockMode = null, $lockVersion = null)
15
 * @method UserInterestedMovie|null findOneBy(array $criteria, array $orderBy = null)
16
 * @method UserInterestedMovie[]    findAll()
17
 * @method UserInterestedMovie[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
18
 */
19
class InterestedMovieRepository extends ServiceEntityRepository
20
{
21 2
    public function __construct(RegistryInterface $registry)
22
    {
23 2
        parent::__construct($registry, UserInterestedMovie::class);
24 2
    }
25
26 2
    public function findOneById(int $interestedMovieId, int $userId): ?UserInterestedMovie
27
    {
28 2
        return $this->findOneBy([
29 2
            'id' => $interestedMovieId,
30 2
            'user' => $userId,
31
        ]);
32
    }
33
34 1
    public function findOneByMovieId(int $movieId, int $userId): ?UserInterestedMovie
35
    {
36 1
        return $this->findOneBy([
37 1
            'movie' => $movieId,
38 1
            'user' => $userId,
39
        ]);
40
    }
41
}
42