Completed
Pull Request — master (#34)
by Krzysztof
02:14
created

ImmutablePaginationAdapter::setItemsPerPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace KGzocha\Searcher\FilterModel\Adapter;
4
5
use KGzocha\Searcher\FilterModel\PaginationFilterModelInterface;
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 PaginationFilterModelInterface
13
{
14
    /**
15
     * @var PaginationFilterModelInterface
16
     */
17
    private $pagination;
18
19
    /**
20
     * @param PaginationFilterModelInterface $pagination
21
     */
22 9
    public function __construct(PaginationFilterModelInterface $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 4
        return $this
59
            ->pagination
60 4
            ->setItemsPerPage(
61 4
                $this->pagination->getItemsPerPage()
62 4
            );
63
    }
64
65
    /**
66
     * @inheritDoc
67
     */
68 4
    public function isImposed()
69
    {
70 4
        return $this->pagination->isImposed();
71
    }
72
}
73