Completed
Pull Request — master (#46)
by Daniel
03:48
created

ImmutablePaginationAdapter::getPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace KGzocha\Searcher\QueryCriteria\Adapter;
4
5
use KGzocha\Searcher\QueryCriteria\PaginationQueryCriteriaInterface;
6
7
/**
8
 * This adapter will not allow to change itemsPerPage parameter in adapter pagination filter model.
9
 * Every other behaviour will stay as it is.
10
 * @author Krzysztof Gzocha <[email protected]>
11
 */
12
class ImmutablePaginationAdapter implements PaginationQueryCriteriaInterface
13
{
14
    /**
15
     * @var PaginationQueryCriteriaInterface
16
     */
17
    private $pagination;
18
19
    /**
20
     * @param PaginationQueryCriteriaInterface $pagination
21
     */
22 9
    public function __construct(PaginationQueryCriteriaInterface $pagination)
23
    {
24 9
        $this->pagination = $pagination;
25 9
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30 3
    public function getPage()
31
    {
32 3
        return $this->pagination->getPage();
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38 4
    public function getItemsPerPage()
39
    {
40 4
        return $this->pagination->getItemsPerPage();
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46 4
    public function setPage($page)
47
    {
48 4
        return $this->pagination->setPage($page);
49
    }
50
51
    /**
52
     * This method will not allow to change items per page.
53
     * On each call it will set the same value
54
     * @inheritDoc
55
     */
56 4
    public function setItemsPerPage($itemsPerPage)
57
    {
58
        return $this
59 4
            ->pagination
60 4
            ->setItemsPerPage(
61 4
                $this->pagination->getItemsPerPage()
62
            );
63
    }
64
65
    /**
66
     * @inheritDoc
67
     */
68 4
    public function shouldBeApplied()
69
    {
70 4
        return $this->pagination->shouldBeApplied();
71
    }
72
}
73