OffsetPaginatedResponse::setOffset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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
Are you sure the doc-type for parameter $total is correct as it would always require null to be passed?
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