Passed
Push — master ( 9e1161...5545f1 )
by Kirill
03:21
created

LimitsTrait::offset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Pagination\Traits;
13
14
/**
15
 * Common functionality with ability to limit selection and specify offsets.
16
 */
17
trait LimitsTrait
18
{
19
    /**
20
     * @var int
21
     */
22
    private $limit = 0;
23
24
    /**
25
     * @var int
26
     */
27
    private $offset = 0;
28
29
    /**
30
     * Set selection limit. Attention, this limit value does not affect values set in paginator but
31
     * only changes pagination window. Set to 0 to disable limiting.
32
     *
33
     * @param int $limit
34
     *
35
     * @return $this
36
     */
37
    public function limit(int $limit = 0)
38
    {
39
        $this->limit = $limit;
40
41
        return $this;
42
    }
43
44
    /**
45
     * @return int
46
     */
47
    public function getLimit(): int
48
    {
49
        return $this->limit;
50
    }
51
52
    /**
53
     * Set selection offset. Attention, this value does not affect associated paginator but only
54
     * changes pagination window.
55
     *
56
     * @param int $offset
57
     *
58
     * @return mixed
59
     */
60
    public function offset(int $offset = 0)
61
    {
62
        $this->offset = $offset;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return int
69
     */
70
    public function getOffset(): int
71
    {
72
        return $this->offset;
73
    }
74
}
75