| Total Complexity | 3 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class NotificationRepository extends AbstractRepository |
||
| 11 | { |
||
| 12 | public function findUnread(string $ownerId = null): Collection |
||
| 13 | { |
||
| 14 | $queryBuilder = $this |
||
| 15 | ->createQueryBuilder('notification') |
||
| 16 | ->where('notification.read = :read') |
||
| 17 | ->setParameter('read', false) |
||
| 18 | ->addOrderBy('notification.updatedAt', 'desc') |
||
| 19 | ->addOrderBy('notification.id', 'desc') |
||
| 20 | ; |
||
| 21 | |||
| 22 | if ($ownerId) { |
||
| 23 | $queryBuilder |
||
| 24 | ->andWhere('notification.ownerId = :owner_id') |
||
| 25 | ->setParameter('owner_id', $ownerId) |
||
| 26 | ; |
||
| 27 | } |
||
| 28 | |||
| 29 | return new ArrayCollection($queryBuilder->getQuery()->getResult()); |
||
| 30 | } |
||
| 31 | |||
| 32 | public function getEntityClass(): string |
||
| 35 | } |
||
| 36 | } |
||
| 37 |