Passed
Push — master ( aec003...e09ad0 )
by Marcel
08:04
created

TeacherAbsenceLessonRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findOneForLesson() 0 10 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\TeacherAbsenceLesson;
6
use App\Entity\TimetableLesson;
7
8
class TeacherAbsenceLessonRepository extends AbstractRepository implements TeacherAbsenceLessonRepositoryInterface {
9
10
    public function findOneForLesson(TimetableLesson $lesson): ?TeacherAbsenceLesson {
11
        return $this->em->createQueryBuilder()
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->em->create...)->getOneOrNullResult() could return the type integer which is incompatible with the type-hinted return App\Entity\TeacherAbsenceLesson|null. Consider adding an additional type-check to rule them out.
Loading history...
12
            ->select('al')
13
            ->from(TeacherAbsenceLesson::class, 'al')
14
            ->leftJoin('al.lesson', 'l')
15
            ->where('l.id = :lesson')
16
            ->setParameter('lesson', $lesson->getId())
17
            ->setMaxResults(1)
18
            ->getQuery()
19
            ->getOneOrNullResult();
20
    }
21
}