<?php

namespace AutoAdmin\Bundle\Cache\Repository;

use AutoAdmin\Bundle\Content\Repository\AbstractContentRepository;
use DateTime;

class CacheLogRepository extends AbstractContentRepository
{
    public function findBefore(DateTime $before, $limit = 100000)
    {
        $qb = $this->createQueryBuilder('cl');
        $qb->where('cl.createdAt < :before');
        $qb->setParameter('before', $before);
        if ($limit) {
            $qb->setMaxResults($limit);
        }
        return $qb->getQuery()->getResult();
    }
}
