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 | public function __construct(array $payload) |
||
32 | |||
33 | /** |
||
34 | * Retorna as colunas filtradas no select |
||
35 | 1 | * @return array |
|
36 | * @throws InvalidColumnNameException |
||
37 | 1 | */ |
|
38 | View Code Duplication | public function getColumns() |
|
60 | |||
61 | /** |
||
62 | * Retorna o limite de linhas |
||
63 | * |
||
64 | 1 | * @return int|null |
|
65 | */ |
||
66 | 1 | View Code Duplication | public function getLimit() |
76 | |||
77 | /** |
||
78 | 1 | * Retorna o offset de linhas |
|
79 | * |
||
80 | * @return int|null |
||
81 | 1 | */ |
|
82 | 1 | View Code Duplication | public function getOffset() |
83 | 1 | { |
|
84 | 1 | if(!isset($this->payload['offset'])) |
|
85 | 1 | return 1; |
|
86 | 1 | ||
87 | if(!is_numeric($this->payload['offset'])) |
||
88 | return 1; |
||
89 | |||
90 | return (int) $this->payload['offset']; |
||
91 | } |
||
133 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.