DemoLessonRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 9
c 1
b 0
f 1
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findAllForCourse() 0 9 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\DemoLesson;
6
use App\Model\CourseInterface;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Persistence\ManagerRegistry;
9
10
/**
11
 * @method DemoLesson|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method DemoLesson|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method DemoLesson[]    findAll()
14
 * @method DemoLesson[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class DemoLessonRepository extends ServiceEntityRepository implements DemoLessonRepositoryInterface
17
{
18
    public function __construct(ManagerRegistry $registry)
19
    {
20
        parent::__construct($registry, DemoLesson::class);
21
    }
22
23
    public function findAllForCourse(CourseInterface $course): array
24
    {
25
        return $this->createQueryBuilder('dl')
26
            ->where('m.course = :course')
27
            ->leftJoin('dl.lesson', 'l')
28
            ->leftJoin('l.module', 'm')
29
            ->setParameter('course', $course)
30
            ->getQuery()
31
            ->getResult();
32
    }
33
}
34