1 | <?php |
||
14 | class SelectPayload |
||
15 | { |
||
16 | /** |
||
17 | * Payload recebido do front-end |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $payload; |
||
22 | |||
23 | /** |
||
24 | * Constrói o payload |
||
25 | * |
||
26 | * @param array $payload |
||
27 | */ |
||
28 | 1 | public function __construct(array $payload) |
|
32 | |||
33 | /** |
||
34 | * Retorna as colunas filtradas no select |
||
35 | * @return array |
||
36 | * @throws InvalidColumnNameException |
||
37 | */ |
||
38 | 1 | public function getColumns() |
|
60 | |||
61 | /** |
||
62 | * Retorna o limite de linhas |
||
63 | * |
||
64 | * @return int|null |
||
65 | */ |
||
66 | 1 | public function getLimit() |
|
76 | |||
77 | /** |
||
78 | * Retorna o offset de linhas |
||
79 | * |
||
80 | * @return int|null |
||
81 | */ |
||
82 | 1 | public function getOffset() |
|
83 | { |
||
84 | 1 | if(!isset($this->payload['offset'])) |
|
85 | 1 | return 1; |
|
86 | |||
87 | if(!is_numeric($this->payload['offset'])) |
||
88 | return 1; |
||
89 | |||
90 | return (int) $this->payload['offset']; |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Retorna a ordem definida pelo usuário em string |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | 1 | public function getOrder() |
|
116 | |||
117 | /** |
||
118 | * Retorna o where do payload de seleção |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | 1 | public function getWhere() |
|
132 | } |
||
133 |