RunManager::getOldLiveRuns()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2.0017

Importance

Changes 0
Metric Value
cc 2
eloc 12
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 18
ccs 12
cts 13
cp 0.9231
crap 2.0017
rs 9.8666
1
<?php
2
3
namespace Dtc\QueueBundle\ORM;
4
5
use Doctrine\ORM\EntityManager;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Doctrine\ORM\QueryBuilder;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\QueryBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Dtc\QueueBundle\Doctrine\DoctrineRunManager;
8
9
class RunManager extends DoctrineRunManager
10
{
11 1
    use CommonTrait;
0 ignored issues
show
introduced by
The trait Dtc\QueueBundle\ORM\CommonTrait requires some properties which are not provided by Dtc\QueueBundle\ORM\RunManager: $generatorType, $idGenerator
Loading history...
12
13 15
    public function getObjectManager()
14
    {
15 15
        return $this->getObjectManagerReset();
16
    }
17
18
    /**
19
     * @return array|mixed
20
     *
21
     * @throws \Exception
22
     */
23 1
    protected function getOldLiveRuns()
24
    {
25
        /** @var EntityManager $objectManager */
26 1
        $objectManager = $this->getObjectManager();
27
        /** @var QueryBuilder $queryBuilder */
28 1
        $queryBuilder = $objectManager->createQueryBuilder();
29 1
        $queryBuilder->select(['r'])
30 1
            ->from($this->getRunClass(), 'r');
31 1
        $time = time() - 86400;
32 1
        $date = \DateTime::createFromFormat('U', strval($time));
33 1
        if (false === $date) {
34
            throw new \Exception("Could not create DateTime object from $time");
35
        }
36 1
        $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
37 1
        $queryBuilder->where('r.lastHeartbeatAt < :date');
38 1
        $queryBuilder->setParameter(':date', $date);
39
40 1
        return $queryBuilder->getQuery()->getResult();
41
    }
42
}
43