LampagerArrayCursor::has()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 11
rs 10
ccs 6
cts 6
cp 1
crap 4
1
<?php
2
3
App::uses('Model', 'Model');
4
App::uses('LampagerColumnAccess', 'Lampager.Model');
5
6
use Lampager\Contracts\Cursor;
7
8
class LampagerArrayCursor implements Cursor
9
{
10
    /** @var array */
11
    protected $cursor;
12
13
    /** @var LampagerColumnAccess */
14
    protected $access;
15
16
    public function __construct(Model $model, array $cursor = [])
17
    {
18 48
        $this->cursor = $cursor;
19
        $this->access = new LampagerColumnAccess($model);
20 48
    }
21 48
22 48
    /**
23
     * {@inheritdoc}
24
     */
25
    public function has(...$columns)
26
    {
27 40
        if (empty($this->cursor)) {
28
            return null;
29 40
        }
30 17
        foreach ($columns as $column) {
31
            if (!$this->access->has($this->cursor, $column)) {
32 23
                return false;
33 23
            }
34 2
        }
35
        return true;
36
    }
37 21
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function get($column)
42
    {
43 24
        return $this->access->get($this->cursor, $column);
44
    }
45
}
46