public function getRequestCount(AuthenticationRecordInterface $authenticationRecord): int
    {
        $fiveMinutesAgo = new \DateTime('now', new \DateTimeZone('UTC'));
        $fiveMinutesAgo->modify('-5 minutes');

        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('COUNT(r.id) AS total')
            ->where('r.authentication = :authentication')
            ->andWhere('r.request_time > :since')
            ->setParameter('authentication', $authenticationRecord)
            ->setParameter('since', $fiveMinutesAgo)
            ->getQuery();

        return $query->getSingleScalarResult();
    }
public function getRequestCount(AuthenticationRecordInterface $authenticationRecord): int
    {
        $fiveMinutesAgo = new \DateTime('now', new \DateTimeZone('UTC'));
        $fiveMinutesAgo->modify('-5 minutes');

        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('COUNT(r.id) AS total')
            ->where('r.authentication = :authentication')
            ->andWhere('r.request_time > :since')
            ->setParameter('authentication', $authenticationRecord)
            ->setParameter('since', $fiveMinutesAgo)
            ->getQuery();

        return $query->getSingleScalarResult();
    }
public function getRequestCount ( AuthenticationRecordInterface $ authenticationRecord ) : int { $ fiveMinutesAgo = new \ DateTime ( 'now' , new \ DateTimeZone ( 'UTC' ) ) ; $ fiveMinutesAgo -> modify ( '-5 minutes' ) ; $ query = $ this -> getRepository ( ) -> createQueryBuilder ( 'r' ) -> select ( 'COUNT(r.id) AS total' ) -> where ( 'r.authentication = :authentication' ) -> andWhere ( 'r.request_time > :since' ) -> setParameter ( 'authentication' , $ authenticationRecord ) -> setParameter ( 'since' , $ fiveMinutesAgo ) -> getQuery ( ) ; return $ query -> getSingleScalarResult ( ) ; }
Get the count of requests in the last 5 minutes

@param AuthenticationRecordInterface $authenticationRecord

@return int
@throws \Doctrine\ORM\NoResultException
@throws \Doctrine\ORM\NonUniqueResultException
Get the count of requests in the last 5 minutes