Passed
Push — 0.x ( fc5333...ca02fa )
by Pavel
03:09
created

CriteriaDto::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[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
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AppBundle\Dto\Paginator;
17
18
use Knp\Component\Pager\PaginatorInterface;
19
20
/**
21
 * Pagination criteria
22
 *
23
 * @see PaginatorInterface
24
 */
25
class CriteriaDto
26
{
27
    /**
28
     * Page number
29
     *
30
     * @var int|null
31
     */
32
    private $page;
33
34
    /**
35
     * Number of items per page
36
     *
37
     * @var int|null
38
     */
39
    private $limit;
40
41
    /**
42
     * Additional options for pagination
43
     *
44
     * @var array
45
     */
46
    private $options;
47
48
    /**
49
     * A set of additional hints for query building
50
     * Usage of this parameter depends on a concrete PaginatorInterface implementer
51
     *
52
     * @var array
53
     */
54
    private $hints;
55
56
    /**
57
     * CriteriaDto constructor.
58
     */
59
    public function __construct()
60
    {
61
        $this->options = [];
62
        $this->hints   = [];
63
    }
64
65
    /**
66
     * Returns page number
67
     *
68
     * @return int|null
69
     */
70
    public function getPage(): ?int
71
    {
72
        return $this->page;
73
    }
74
75
    /**
76
     * Sets page number
77
     *
78
     * @param int|null $page Page number
79
     *
80
     * @return void
81
     */
82
    public function setPage(?int $page): void
83
    {
84
        $this->page = $page;
85
    }
86
87
    /**
88
     * Returns number of items per page
89
     *
90
     * @return int|null
91
     */
92
    public function getLimit(): ?int
93
    {
94
        return $this->limit;
95
    }
96
97
    /**
98
     * Sets number of items per page
99
     *
100
     * @param int|null $limit Number of items per page
101
     *
102
     * @return void
103
     */
104
    public function setLimit(?int $limit): void
105
    {
106
        $this->limit = $limit;
107
    }
108
109
    /**
110
     * Returns additional options for pagination
111
     *
112
     * @return array
113
     */
114
    public function getOptions(): array
115
    {
116
        return $this->options;
117
    }
118
119
    /**
120
     * Sets additional options for pagination
121
     *
122
     * @param array $options Additional options for pagination
123
     *
124
     * @return void
125
     */
126
    public function setOptions(array $options): void
127
    {
128
        $this->options = $options;
129
    }
130
131
    /**
132
     * Returns a set of additional hints for query building
133
     *
134
     * @return array
135
     */
136
    public function getHints(): array
137
    {
138
        return $this->hints;
139
    }
140
141
    /**
142
     * Adds an additional hint for query building
143
     *
144
     * @param string $name Hint name
145
     * @param mixed  $data Hint data
146
     *
147
     * @return void
148
     */
149
    public function addHint(string $name, $data): void
150
    {
151
        $this->hints[$name] = $data;
152
    }
153
}
154