| @@ 38-59 (lines=22) @@ | ||
| 35 | * @return array |
|
| 36 | * @throws InvalidColumnNameException |
|
| 37 | */ |
|
| 38 | public function getColumns() |
|
| 39 | { |
|
| 40 | // Se nenhuma coluna foi definida todas serão retornadas |
|
| 41 | if(!isset($this->payload['columns']) || !is_array($this->payload['columns'])) |
|
| 42 | return ['*']; |
|
| 43 | ||
| 44 | $regex = '/^[a-zA-Z_][a-zA-Z0-9_]*$/'; |
|
| 45 | $columns = array(); |
|
| 46 | ||
| 47 | foreach ($this->payload['columns'] as $column){ |
|
| 48 | // Valida o nome da coluna |
|
| 49 | if(!is_string($column) || !preg_match($regex, $column)) |
|
| 50 | throw new InvalidColumnNameException(); |
|
| 51 | ||
| 52 | $columns[] = $column; |
|
| 53 | } |
|
| 54 | ||
| 55 | if(count($columns) == 0) |
|
| 56 | return ['*']; |
|
| 57 | ||
| 58 | return $columns; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Retorna o limite de linhas |
|
| @@ 38-59 (lines=22) @@ | ||
| 35 | * @return array |
|
| 36 | * @throws InvalidColumnNameException |
|
| 37 | */ |
|
| 38 | public function getColumns() |
|
| 39 | { |
|
| 40 | // Se nenhuma coluna foi definida todas serão retornadas |
|
| 41 | if(!isset($this->payload['columns']) || !is_array($this->payload['columns'])) |
|
| 42 | return ['*']; |
|
| 43 | ||
| 44 | $regex = '/^[a-zA-Z_][a-zA-Z0-9_]*$/'; |
|
| 45 | $columns = array(); |
|
| 46 | ||
| 47 | foreach ($this->payload['columns'] as $column){ |
|
| 48 | // Valida o nome da coluna |
|
| 49 | if(!is_string($column) || !preg_match($regex, $column)) |
|
| 50 | throw new InvalidColumnNameException(); |
|
| 51 | ||
| 52 | $columns[] = $column; |
|
| 53 | } |
|
| 54 | ||
| 55 | if(count($columns) == 0) |
|
| 56 | return ['*']; |
|
| 57 | ||
| 58 | return $columns; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Retorna o limite de linhas |
|