Completed
Push — develop ( 8cb156...27be84 )
by
unknown
17:07
created

JobSelectPaginator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Applications\Paginator;
12
13
use Core\Paginator\Adapter\DoctrineMongoCursor;
14
use Zend\Paginator\Paginator;
15
16
/**
17
 * Paginator for Job title select element.
18
 * 
19
 * @author Mathias Gelhausen <[email protected]>
20
 * @since 0.29.2
21
 */
22
class JobSelectPaginator extends Paginator
23
{
24
    /**
25
     * @var \Jobs\Repository\Job
26
     */
27
    private $repository;
28
    
29
    public function __construct($repository)
30
    {
31
        $this->repository = $repository;
32
    }
33
34
    /**
35
     * Set the search criteria.
36
     *
37
     * @param string $q
38
     *
39
     * @return self
40
     */
41
    public function search($q)
42
    {
43
        /* @var \Doctrine\ODM\MongoDB\Query\Builder $qb */
44
        $qb = $this->repository->createQueryBuilder();
45
        $qb->field('title')->equals(new \MongoRegex('/' . addslashes($q) . '/i'));
46
        $cursor = $qb->getQuery()->execute();
47
48
        $adapter = new DoctrineMongoCursor($cursor);
49
        parent::__construct($adapter);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (__construct() instead of search()). Are you sure this is correct? If so, you might want to change this to $this->__construct().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
50
51
        return $this;
52
    }
53
}