PaginableList::setOffset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace linkprofit\AmoCRM\traits;
4
5
/**
6
 * Trait PaginableList
7
 * @package linkprofit\AmoCRM\traits
8
 */
9
trait PaginableList
10
{
11
    /**
12
     * @var int
13
     */
14
    protected $listLimit;
15
16
    /**
17
     * @var int
18
     */
19
    protected $listOffset;
20
21
    /**
22
     * @param $limit
23
     *
24
     * @return $this
25
     */
26
    public function setLimit($limit)
27
    {
28
        $this->listLimit = $limit;
29
30
        return $this;
31
    }
32
33
    /**
34
     * @param $offset
35
     *
36
     * @return $this
37
     */
38
    public function setOffset($offset)
39
    {
40
        $this->listOffset = $offset;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @param array $query
47
     *
48
     * @return array
49
     */
50 2
    public function addPaginationToQuery($query = [])
51
    {
52 2
        if ($this->listLimit !== null) {
53
            $query['limit_rows'] = $this->listLimit;
54
        }
55
56 2
        if ($this->listOffset !== null) {
57
            $query['limit_offset'] = $this->listOffset;
58
        }
59
60 2
        return $query;
61
    }
62
}