mediamonks /
php-rest-api
| 1 | <?php |
||
| 2 | |||
| 3 | namespace MediaMonks\RestApi\Response; |
||
| 4 | |||
| 5 | class OffsetPaginatedResponse extends AbstractPaginatedResponse implements PaginatedResponseInterface |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var int |
||
| 9 | */ |
||
| 10 | protected $offset; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param $data |
||
| 14 | * @param $offset |
||
| 15 | * @param $limit |
||
| 16 | * @param null $total |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 17 | */ |
||
| 18 | 5 | public function __construct($data, $offset, $limit, $total = null) |
|
| 19 | { |
||
| 20 | 5 | parent::__construct($data, $limit, $total); |
|
| 21 | 5 | $this->offset = $offset; |
|
| 22 | 5 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @return int |
||
| 26 | */ |
||
| 27 | 4 | public function getOffset() |
|
| 28 | { |
||
| 29 | 4 | return $this->offset; |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param int $offset |
||
| 34 | */ |
||
| 35 | 1 | public function setOffset($offset) |
|
| 36 | { |
||
| 37 | 1 | $this->offset = $offset; |
|
| 38 | 1 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | 2 | public function toArray() |
|
| 44 | { |
||
| 45 | $data = [ |
||
| 46 | 2 | 'offset' => $this->getOffset(), |
|
| 47 | 2 | 'limit' => $this->getLimit(), |
|
| 48 | 2 | ]; |
|
| 49 | 2 | if (!is_null($this->getTotal())) { |
|
| 50 | 2 | $data['total'] = $this->getTotal(); |
|
| 51 | 2 | } |
|
| 52 | |||
| 53 | 2 | return $data; |
|
| 54 | } |
||
| 55 | } |
||
| 56 |