Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function getUserScore(int $userId, int $attendanceId, ?int $groupId = null): int |
||
21 | { |
||
22 | $qb = $this->createQueryBuilder('sheet') |
||
23 | ->select('SUM(sheet.presence) as score') |
||
24 | ->join('sheet.attendanceCalendar', 'calendar') |
||
25 | ->where('calendar.attendance = :attendanceId') |
||
26 | ->andWhere('sheet.user = :userId') |
||
27 | ->setParameter('attendanceId', $attendanceId) |
||
28 | ->setParameter('userId', $userId); |
||
29 | |||
30 | if ($groupId) { |
||
|
|||
31 | $qb->join('calendar.groups', 'groups') |
||
32 | ->andWhere('groups.group = :groupId') |
||
33 | ->setParameter('groupId', $groupId); |
||
34 | } |
||
35 | |||
36 | return (int) $qb->getQuery()->getSingleScalarResult(); |
||
37 | } |
||
39 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: