Cursor   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 144
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 144
ccs 26
cts 26
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getCurrent() 0 4 1
A setCurrent() 0 6 1
A getPrev() 0 4 1
A setPrev() 0 6 1
A getNext() 0 4 1
A setNext() 0 6 1
A getCount() 0 4 1
A setCount() 0 6 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 mixed $current
54
     * @param mixed $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 mixed $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 mixed $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 mixed $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