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

ImmutablePaginationAdapter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 62
rs 10
ccs 15
cts 15
cp 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPage() 0 4 1
A getItemsPerPage() 0 4 1
A setPage() 0 4 1
A setItemsPerPage() 0 8 1
A shouldBeApplied() 0 4 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