Completed
Push — master ( e02161...971421 )
by Matthew
12:50
created

LiveJobGridSource   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 36
loc 36
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 4 4 1
A __construct() 7 7 1
A getColumns() 9 9 2
A getQueryBuilder() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Dtc\QueueBundle\ORM;
4
5
use Doctrine\ORM\EntityManager;
6
use Dtc\GridBundle\Grid\Source\EntityGridSource;
7
8 View Code Duplication
class LiveJobGridSource extends EntityGridSource
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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