Completed
Pull Request — master (#602)
by Tom
07:15
created

DoctrinePaginator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 55
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineORMModule\Paginator\Adapter;
6
7
use Doctrine\ORM\Tools\Pagination\Paginator;
8
use Laminas\Paginator\Adapter\AdapterInterface;
9
10
/**
11
 * Paginator adapter for the Laminas\Paginator component
12
 *
13
 * @link    http://www.doctrine-project.org/
14
 */
15
class DoctrinePaginator implements AdapterInterface
16
{
17
    protected Paginator $paginator;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
18
19
    /**
20
     * Constructor
21
     */
22
    public function __construct(Paginator $paginator)
23
    {
24
        $this->paginator = $paginator;
25
    }
26
27
    public function setPaginator(Paginator $paginator) : self
28
    {
29
        $this->paginator = $paginator;
30
    }
31
32
    public function getPaginator() : Paginator
33
    {
34
        return $this->paginator;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40
    public function getItems($offset, $itemCountPerPage)
41
    {
42
        $this->paginator
43
             ->getQuery()
44
             ->setFirstResult($offset)
45
             ->setMaxResults($itemCountPerPage);
46
47
        return $this->paginator->getIterator();
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53
    public function count()
54
    {
55
        return $this->paginator->count();
56
    }
57
}
58