|
1
|
|
|
<?php namespace Limoncello\Models; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2015-2016 [email protected] (www.neomerx.com) |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
use Limoncello\Models\Contracts\PaginatedDataInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @package Limoncello\Models |
|
23
|
|
|
*/ |
|
24
|
|
|
class PaginatedData implements PaginatedDataInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** @var mixed */ |
|
27
|
|
|
private $data; |
|
28
|
|
|
|
|
29
|
|
|
/** @var bool */ |
|
30
|
|
|
private $isCollection; |
|
31
|
|
|
|
|
32
|
|
|
/** @var bool */ |
|
33
|
|
|
private $hasMoreItems; |
|
34
|
|
|
|
|
35
|
|
|
/** @var int|null */ |
|
36
|
|
|
private $offset; |
|
37
|
|
|
|
|
38
|
|
|
/** @var int|null */ |
|
39
|
|
|
private $size; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param mixed $data |
|
43
|
|
|
* @param bool $isCollection |
|
44
|
|
|
* @param bool $hasMoreItems |
|
45
|
|
|
* @param int|null $offset |
|
46
|
|
|
* @param int|null $size |
|
47
|
|
|
*/ |
|
48
|
2 |
|
public function __construct($data, $isCollection = false, $hasMoreItems = false, $offset = null, $size = null) |
|
49
|
|
|
{ |
|
50
|
2 |
|
$this->data = $data; |
|
51
|
2 |
|
$this->isCollection = $isCollection; |
|
52
|
2 |
|
$this->hasMoreItems = $hasMoreItems; |
|
53
|
2 |
|
$this->offset = $offset; |
|
54
|
2 |
|
$this->size = $size; |
|
55
|
2 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @inheritdoc |
|
59
|
|
|
*/ |
|
60
|
2 |
|
public function getData() |
|
61
|
|
|
{ |
|
62
|
2 |
|
return $this->data; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @inheritdoc |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function isCollection() |
|
69
|
|
|
{ |
|
70
|
1 |
|
return $this->isCollection; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @inheritdoc |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function hasMoreItems() |
|
77
|
|
|
{ |
|
78
|
1 |
|
return $this->hasMoreItems; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @inheritdoc |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function getOffset() |
|
85
|
|
|
{ |
|
86
|
1 |
|
return $this->offset; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @inheritdoc |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public function getSize() |
|
93
|
|
|
{ |
|
94
|
1 |
|
return $this->size; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|