Completed
Push — master ( b3b1dd...98ca64 )
by Matthew
06:26
created

LiveJobGridSource::getCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dtc\QueueBundle\ORM;
4
5
use Doctrine\ORM\EntityManager;
6
use Dtc\GridBundle\Grid\Source\EntityGridSource;
7
8
class LiveJobGridSource extends EntityGridSource
9
{
10
    protected $jobManager;
11
12
    public function getId()
13
    {
14
        return 'dtc_queue.grid_source.live_jobs.orm';
15
    }
16
17
    public function __construct(JobManager $jobManager)
18
    {
19
        $this->jobManager = $jobManager;
20
        /** @var EntityManager $entityManager */
21
        $entityManager = $jobManager->getObjectManager();
22
        parent::__construct($entityManager, $jobManager->getObjectName());
23
    }
24
25
    public function getColumns()
26
    {
27
        if ($columns = parent::getColumns()) {
28
            return $columns;
29
        }
30
        $this->autoDiscoverColumns();
31
32
        return parent::getColumns();
33
    }
34
35
    protected function getQueryBuilder()
36
    {
37
        $queryBuilder = $this->jobManager->getJobQueryBuilder();
38
        $queryBuilder->setFirstResult($this->offset)
39
                     ->setMaxResults($this->limit);
40
41
        return $queryBuilder;
42
    }
43
44
    public function getCount()
45
    {
46
        $qb = $this->getQueryBuilder();
47
        $qb->add('select', 'count(j)')
0 ignored issues
show
Documentation introduced by
'count(j)' is of type string, but the function expects a object<Doctrine\ORM\Query\Expr\Base>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
            ->setFirstResult(null)
49
            ->setMaxResults(null);
50
51
        return $qb->getQuery()
52
            ->getSingleScalarResult();
53
    }
54
}
55