OffsetPaginatedResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 49
ccs 17
cts 17
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getOffset() 0 3 1
A setOffset() 0 3 1
A __construct() 0 4 1
A toArray() 0 11 2
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