CronJobResultRepository::deleteOldLogs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 7
c 1
b 1
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Alpixel\Bundle\CronBundle\Entity\Repository;
4
5
use Alpixel\Bundle\CronBundle\Entity\CronJob;
6
use Alpixel\Bundle\CronBundle\Entity\CronJobResult;
7
use Doctrine\ORM\EntityRepository;
8
9
class CronJobResultRepository extends EntityRepository
10
{
11
    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...
12
    {
13
        $this
14
            ->getEntityManager()
15
            ->createQuery('DELETE CronBundle:CronJobResult result')
16
            ->getResult();
17
    }
18
19
    public function findLastRunForCronJob(CronJob $job)
20
    {
21
        return $this->createQueryBuilder('cjr')
22
                    ->select('MAX(cjr.runAt)')
23
                    ->andWhere('cjr.job = :job')
24
                    ->andWhere('cjr.result = :success')
25
                    ->setParameter('job', $job)
26
                    ->setParameter('success', CronJobResult::SUCCEEDED)
27
                    ->getQuery()
28
                    ->getSingleScalarResult();
29
    }
30
}
31