RunManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 32
ccs 15
cts 16
cp 0.9375
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getObjectManager() 0 3 1
A getOldLiveRuns() 0 18 2
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