| Total Complexity | 3 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class MessageRepository extends ServiceEntityRepository |
||
| 14 | { |
||
| 15 | public function __construct(ManagerRegistry $registry) |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getPosition($message) |
||
| 21 | { |
||
| 22 | $qb = $this->createQueryBuilder('message') |
||
| 23 | ->select('COUNT(message.id)') |
||
| 24 | ->where('message.id <= :id') |
||
| 25 | ->setParameter('id', $message->getId()); |
||
| 26 | |||
| 27 | return $qb->getQuery() |
||
| 28 | ->getOneOrNullResult(); |
||
| 29 | } |
||
| 30 | |||
| 31 | |||
| 32 | /** |
||
| 33 | * @param Topic $topic |
||
| 34 | * @return mixed |
||
| 35 | * @throws NonUniqueResultException |
||
| 36 | */ |
||
| 37 | public function getLastMessageId(Topic $topic) |
||
| 46 | } |
||
| 47 | } |
||
| 48 |