Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
6.67% |
1 / 15 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
MovieRepository | |
6.67% |
1 / 15 |
|
25.00% |
1 / 4 |
35.27 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
add | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
remove | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
findBySearch | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Repository; |
4 | |
5 | use App\Entity\Movie; |
6 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
7 | use Doctrine\Persistence\ManagerRegistry; |
8 | |
9 | /** |
10 | * @extends ServiceEntityRepository<Movie> |
11 | * |
12 | * @method Movie|null find($id, $lockMode = null, $lockVersion = null) |
13 | * @method Movie|null findOneBy(array $criteria, array $orderBy = null) |
14 | * @method Movie[] findAll() |
15 | * @method Movie[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
16 | */ |
17 | class MovieRepository extends ServiceEntityRepository |
18 | { |
19 | public function __construct(ManagerRegistry $registry) |
20 | { |
21 | parent::__construct($registry, Movie::class); |
22 | } |
23 | |
24 | public function add(Movie $entity, bool $flush = false): void |
25 | { |
26 | $this->getEntityManager()->persist($entity); |
27 | |
28 | if ($flush) { |
29 | $this->getEntityManager()->flush(); |
30 | } |
31 | } |
32 | |
33 | public function remove(Movie $entity, bool $flush = false): void |
34 | { |
35 | $this->getEntityManager()->remove($entity); |
36 | |
37 | if ($flush) { |
38 | $this->getEntityManager()->flush(); |
39 | } |
40 | } |
41 | |
42 | public function findBySearch($search) |
43 | { |
44 | // alias m Pour Movie |
45 | return $this->createQueryBuilder('m') |
46 | // where title like <search> |
47 | ->where('m.title LIKE :search') |
48 | ->setParameter('search', '%' . $search . '%') |
49 | // ->setParameter('search', "% $search %") |
50 | |
51 | ->orderBy('m.title', 'ASC') |
52 | ->getQuery() |
53 | ->getResult(); |
54 | } |
55 | |
56 | // /** |
57 | // * @return Movie[] Returns an array of Movie objects |
58 | // */ |
59 | // public function findByExampleField($value): array |
60 | // { |
61 | // return $this->createQueryBuilder('m') |
62 | // ->andWhere('m.exampleField = :val') |
63 | // ->setParameter('val', $value) |
64 | // ->orderBy('m.id', 'ASC') |
65 | // ->setMaxResults(10) |
66 | // ->getQuery() |
67 | // ->getResult() |
68 | // ; |
69 | // } |
70 | |
71 | // public function findOneBySomeField($value): ?Movie |
72 | // { |
73 | // return $this->createQueryBuilder('m') |
74 | // ->andWhere('m.exampleField = :val') |
75 | // ->setParameter('val', $value) |
76 | // ->getQuery() |
77 | // ->getOneOrNullResult() |
78 | // ; |
79 | // } |
80 | } |