CursorPaginatedResponse   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 73
ccs 24
cts 24
cp 1
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setAfter() 0 3 1
A getAfter() 0 3 1
A getBefore() 0 3 1
A toArray() 0 12 2
A setBefore() 0 3 1
1
<?php
2
3
namespace MediaMonks\RestApi\Response;
4
5
class CursorPaginatedResponse extends AbstractPaginatedResponse implements PaginatedResponseInterface
6
{
7
    /**
8
     * @var mixed
9
     */
10
    protected $before;
11
12
    /**
13
     * @var mixed
14
     */
15
    protected $after;
16
17
    /**
18
     * @param $data
19
     * @param $before
20
     * @param $after
21
     * @param $limit
22
     * @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...
23
     */
24 5
    public function __construct($data, $before, $after, $limit, $total = null)
25
    {
26 5
        parent::__construct($data, $limit, $total);
27 5
        $this->before = $before;
28 5
        $this->after = $after;
29 5
    }
30
31
    /**
32
     * @return mixed
33
     */
34 5
    public function getBefore()
35
    {
36 5
        return $this->before;
37
    }
38
39
    /**
40
     * @param mixed $before
41
     */
42 1
    public function setBefore($before)
43
    {
44 1
        $this->before = $before;
45 1
    }
46
47
    /**
48
     * @return mixed
49
     */
50 5
    public function getAfter()
51
    {
52 5
        return $this->after;
53
    }
54
55
    /**
56
     * @param mixed $after
57
     */
58 1
    public function setAfter($after)
59
    {
60 1
        $this->after = $after;
61 1
    }
62
63
    /**
64
     * @return array
65
     */
66 3
    public function toArray()
67
    {
68
        $data = [
69 3
            'before' => $this->getBefore(),
70 3
            'after'  => $this->getAfter(),
71 3
            'limit'  => $this->getLimit(),
72 3
        ];
73 3
        if (!is_null($this->getTotal())) {
74 2
            $data['total'] = $this->getTotal();
75 2
        }
76
77 3
        return $data;
78
    }
79
}
80