CronJobRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 25
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKnownJobs() 0 12 2
A findDueTasks() 0 9 1
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