Completed
Push — master ( f7a0cf...f46d89 )
by Benjamin
02:37
created

CronJobResultRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 2
c 5
b 1
f 0
lcom 0
cbo 4
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteOldLogs() 0 7 1
A findLastRunForCronJob() 0 10 1
1
<?php
2
3
namespace Alpixel\Bundle\CronBundle\Entity\Repository;
4
5
use Alpixel\Bundle\CronBundle\Entity\CronJob;
6
use Doctrine\ORM\EntityRepository;
7
8
class CronJobResultRepository extends EntityRepository
9
{
10
    public function deleteOldLogs(CronJob $job = null)
0 ignored issues
show
Unused Code introduced by
The parameter $job is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
11
    {
12
        $this
13
            ->getEntityManager()
14
            ->createQuery('DELETE CronBundle:CronJobResult result')
15
            ->getResult();
16
    }
17
18
    public function findLastRunForCronJob(CronJob $job)
19
    {
20
        return $this->createQueryBuilder('cjr')
21
                    ->select('MAX(cjr.runAt)')
22
                    ->andWhere('cjr.job = :job')
23
                    ->andWhere('cjr.result = true')
24
                    ->setParameter('job', $job)
25
                    ->getQuery()
26
                    ->getSingleScalarResult();
27
    }
28
}
29