Completed
Pull Request — master (#304)
by Benoît
03:33
created

Cursor::getPrev()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the League\Fractal package.
5
 *
6
 * (c) Phil Sturgeon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\Fractal\Pagination;
13
14
/**
15
 * A generic cursor adapter.
16
 *
17
 * @author Isern Palaus <[email protected]>
18
 * @author Michele Massari <[email protected]>
19
 */
20
class Cursor implements CursorInterface
21
{
22
    /**
23
     * Current cursor value.
24
     *
25
     * @var mixed
26
     */
27
    protected $current;
28
29
    /**
30
     * Previous cursor value.
31
     *
32
     * @var mixed
33
     */
34
    protected $prev;
35
36
    /**
37
     * Next cursor value.
38
     *
39
     * @var mixed
40
     */
41
    protected $next;
42
43
    /**
44
     * Items being held for the current cursor position.
45
     *
46
     * @var int
47
     */
48
    protected $count;
49
50
    /**
51
     * Create a new Cursor instance.
52
     *
53
     * @param int   $current
54
     * @param null  $prev
55
     * @param mixed $next
56
     * @param int   $count
57
     *
58
     * @return void
59
     */
60 2
    public function __construct($current = null, $prev = null, $next = null, $count = null)
61
    {
62 2
        $this->current = $current;
63 2
        $this->prev = $prev;
64 2
        $this->next = $next;
65 2
        $this->count = $count;
66 2
    }
67
68
    /**
69
     * Get the current cursor value.
70
     *
71
     * @return mixed
72
     */
73 2
    public function getCurrent()
74
    {
75 2
        return $this->current;
76
    }
77
78
    /**
79
     * Set the current cursor value.
80
     *
81
     * @param int $current
82
     *
83
     * @return Cursor
84
     */
85 1
    public function setCurrent($current)
86
    {
87 1
        $this->current = $current;
88
89 1
        return $this;
90
    }
91
92
    /**
93
     * Get the prev cursor value.
94
     *
95
     * @return mixed
96
     */
97 2
    public function getPrev()
98
    {
99 2
        return $this->prev;
100
    }
101
102
    /**
103
     * Set the prev cursor value.
104
     *
105
     * @param int $prev
106
     *
107
     * @return Cursor
108
     */
109 1
    public function setPrev($prev)
110
    {
111 1
        $this->prev = $prev;
112
113 1
        return $this;
114
    }
115
116
    /**
117
     * Get the next cursor value.
118
     *
119
     * @return mixed
120
     */
121 2
    public function getNext()
122
    {
123 2
        return $this->next;
124
    }
125
126
    /**
127
     * Set the next cursor value.
128
     *
129
     * @param int $next
130
     *
131
     * @return Cursor
132
     */
133 1
    public function setNext($next)
134
    {
135 1
        $this->next = $next;
136
137 1
        return $this;
138
    }
139
140
    /**
141
     * Returns the total items in the current cursor.
142
     *
143
     * @return int
144
     */
145 2
    public function getCount()
146
    {
147 2
        return $this->count;
148
    }
149
150
    /**
151
     * Set the total items in the current cursor.
152
     *
153
     * @param int $count
154
     *
155
     * @return Cursor
156
     */
157 1
    public function setCount($count)
158
    {
159 1
        $this->count = $count;
160
161 1
        return $this;
162
    }
163
}
164