Completed
Push — development ( ea08ae...a063ea )
by Volodymyr
15:59
created

AkeneoResourcePage   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 116
rs 10
c 0
b 0
f 0
wmc 12

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getPreviousPage() 0 10 2
A hasPreviousPage() 0 4 1
A getFirstPage() 0 7 1
A hasNextPage() 0 4 1
A getNextLink() 0 4 1
A __construct() 0 4 1
A getItems() 0 4 1
A getNextPage() 0 10 2
A getPreviousLink() 0 4 1
A getCount() 0 4 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper;
9
10
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
11
12
class AkeneoResourcePage implements AkeneoResourcePageInterface
13
{
14
    /**
15
     * @var \Akeneo\Pim\ApiClient\Pagination\PageInterface $page
16
     */
17
    protected $page;
18
19
    /**
20
     * @var \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface
21
     */
22
    protected $wrapperFactory;
23
24
    /**
25
     * @param \Akeneo\Pim\ApiClient\Pagination\PageInterface $page
26
     * @param \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface $wrapperFactory
27
     */
28
    public function __construct(PageInterface $page, WrapperFactoryInterface $wrapperFactory)
29
    {
30
        $this->page = $page;
31
        $this->wrapperFactory = $wrapperFactory;
32
    }
33
34
    /**
35
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface
36
     */
37
    public function getFirstPage()
38
    {
39
        $firstPage = $this->page
40
            ->getFirstPage();
41
42
        return $this->wrapperFactory
43
            ->createAkeneoPage($firstPage);
44
    }
45
46
    /**
47
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface|null
48
     */
49
    public function getPreviousPage()
50
    {
51
        $previousPage = $this->page
52
            ->getPreviousPage();
53
        if (!$previousPage) {
54
            return null;
55
        }
56
57
        return $this->wrapperFactory
58
            ->createAkeneoPage($previousPage);
59
    }
60
61
    /**
62
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface|null
63
     */
64
    public function getNextPage()
65
    {
66
        $nextPage = $this->page
67
            ->getNextPage();
68
        if (!$nextPage) {
69
            return null;
70
        }
71
72
        return $this->wrapperFactory
73
            ->createAkeneoPage($nextPage);
74
    }
75
76
    /**
77
     * @return int|null
78
     */
79
    public function getCount()
80
    {
81
        return $this->page
82
            ->getCount();
83
    }
84
85
    /**
86
     * @return array
87
     */
88
    public function getItems()
89
    {
90
        return $this->page
91
            ->getItems();
92
    }
93
94
    /**
95
     * @return bool
96
     */
97
    public function hasNextPage()
98
    {
99
        return $this->page
100
            ->hasNextPage();
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    public function hasPreviousPage()
107
    {
108
        return $this->page
109
            ->hasPreviousPage();
110
    }
111
112
    /**
113
     * @return string|null
114
     */
115
    public function getNextLink()
116
    {
117
        return $this->page
118
            ->getNextLink();
119
    }
120
121
    /**
122
     * @return string|null
123
     */
124
    public function getPreviousLink()
125
    {
126
        return $this->page
127
            ->getNextLink();
128
    }
129
}
130