Lines 100.00% 3 / 3
Functions and Methods 100.00% 3 / 3
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
AgentStatRepository 100.00% 3 / 3 100.00% 3 / 3 3 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 findByOwner 100.00% 1 / 1 100.00% 1 / 1 1
 has 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Repository;
6
7use App\Entity\AgentStat;
8use App\Entity\User;
9use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
10use Doctrine\Persistence\ManagerRegistry;
11
12/**
13 * @extends ServiceEntityRepository<AgentStat>
14 */
15class AgentStatRepository extends ServiceEntityRepository
16{
17    public function __construct(ManagerRegistry $registry)
18    {
19        parent::__construct($registry, AgentStat::class);
20    }
21
22    /**
23     * @return AgentStat[]
24     */
25    public function findByOwner(User $owner): array
26    {
27        return $this->findBy(['owner' => $owner], ['datetime' => 'DESC', 'id' => 'DESC']);
28    }
29
30    public function has(User $owner, \DateTimeImmutable $datetime): bool
31    {
32        return null !== $this->findOneBy(['owner' => $owner, 'datetime' => $datetime]);
33    }
34}