CronJobRepository::findDueTasks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\CronBundle\Entity\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
7
class CronJobRepository extends EntityRepository
8
{
9
    public function getKnownJobs()
10
    {
11
        $data = $this->getEntityManager()
12
                     ->createQuery('SELECT job.command FROM CronBundle:CronJob job')
13
                     ->getScalarResult();
14
        $toRet = [];
15
        foreach ($data as $datum) {
16
            $toRet[] = $datum['command'];
17
        }
18
19
        return $toRet;
20
    }
21
22
    public function findDueTasks()
23
    {
24
        return $this->getEntityManager()
25
                    ->createQuery('SELECT job FROM CronBundle:CronJob job
26
                                   WHERE job.nextRun <= :curTime
27
                                   AND job.enabled = 1')
28
                    ->setParameter('curTime', new \DateTime())
29
                    ->getResult();
30
    }
31
}
32