ArrayCursor   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A has() 0 12 4
A get() 0 4 2
1
<?php
2
3
namespace mav3rick177\RapidPagination\Base;
4
5
use mav3rick177\RapidPagination\Base\Contracts\Cursor;
6
7
/**
8
 * Default implementation for Cursor
9
 */
10
class ArrayCursor implements Cursor
11
{
12
    /** @var int[]|string[] */
13
    protected $cursor;
14
15
    /**
16
     * @param int[]|string[] $cursor
17
     */
18 17
    public function __construct(array $cursor)
19
    {
20 17
        $this->cursor = $cursor;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 17
    public function has(...$columns)
27
    {
28 17
        if (empty($this->cursor)) {
29 7
            return null;
30
        }
31 10
        foreach ($columns as $column) {
32 10
            if (!isset($this->cursor[$column])) {
33
                return false;
34
            }
35
        }
36 10
        return true;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 10
    public function get($column)
43
    {
44 10
        return isset($this->cursor[$column]) ? $this->cursor[$column] : null;
45
    }
46
}
47