Completed
Push — master ( 7a35bc...7eff79 )
by Krzysztof
05:49 queued 02:58
created

ImmutablePaginationAdapter::setItemsPerPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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