ScheduledMessageRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 2
b 0
f 0
dl 0
loc 17
ccs 3
cts 12
cp 0.25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findDispatchable() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\MessageSchedulerBundle\Repository;
6
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Persistence\ManagerRegistry;
9
use Safe\DateTime;
10
use Setono\MessageSchedulerBundle\Entity\ScheduledMessage;
11
12
class ScheduledMessageRepository extends ServiceEntityRepository implements ScheduledMessageRepositoryInterface
13
{
14 1
    public function __construct(ManagerRegistry $registry)
15
    {
16 1
        parent::__construct($registry, ScheduledMessage::class);
17 1
    }
18
19
    public function findDispatchable(): array
20
    {
21
        return $this->createQueryBuilder('o')
22
            ->andWhere('o.dispatchAt <= :now')
23
            ->andWhere('o.state = :state')
24
            ->setParameter('now', new DateTime())
25
            ->setParameter('state', ScheduledMessage::STATE_PENDING)
26
            ->setMaxResults(100) // this is just a very basic 'hack' to prevent memory problems
27
            ->getQuery()
28
            ->getResult()
29
        ;
30
    }
31
}
32