@@ -38,22 +38,25 @@ discard block |
||
| 38 | 38 | public function getColumns() |
| 39 | 39 | { |
| 40 | 40 | // Se nenhuma coluna foi definida todas serão retornadas |
| 41 | - if(!isset($this->payload['columns']) || !is_array($this->payload['columns'])) |
|
| 42 | - return ['*']; |
|
| 41 | + if(!isset($this->payload['columns']) || !is_array($this->payload['columns'])) { |
|
| 42 | + return ['*']; |
|
| 43 | + } |
|
| 43 | 44 | |
| 44 | 45 | $regex = '/^[a-zA-Z_][a-zA-Z0-9_]*$/'; |
| 45 | 46 | $columns = array(); |
| 46 | 47 | |
| 47 | 48 | foreach ($this->payload['columns'] as $column){ |
| 48 | 49 | // Valida o nome da coluna |
| 49 | - if(!is_string($column) || !preg_match($regex, $column)) |
|
| 50 | - throw new InvalidColumnNameException(); |
|
| 50 | + if(!is_string($column) || !preg_match($regex, $column)) { |
|
| 51 | + throw new InvalidColumnNameException(); |
|
| 52 | + } |
|
| 51 | 53 | |
| 52 | 54 | $columns[] = $column; |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | - if(count($columns) == 0) |
|
| 56 | - return ['*']; |
|
| 57 | + if(count($columns) == 0) { |
|
| 58 | + return ['*']; |
|
| 59 | + } |
|
| 57 | 60 | |
| 58 | 61 | return $columns; |
| 59 | 62 | } |
@@ -65,11 +68,13 @@ discard block |
||
| 65 | 68 | */ |
| 66 | 69 | public function getLimit() |
| 67 | 70 | { |
| 68 | - if(!isset($this->payload['limit'])) |
|
| 69 | - return null; |
|
| 71 | + if(!isset($this->payload['limit'])) { |
|
| 72 | + return null; |
|
| 73 | + } |
|
| 70 | 74 | |
| 71 | - if(!is_int($this->payload['limit'])) |
|
| 72 | - return null; |
|
| 75 | + if(!is_int($this->payload['limit'])) { |
|
| 76 | + return null; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | 79 | return $this->payload['limit']; |
| 75 | 80 | } |
@@ -83,8 +88,9 @@ discard block |
||
| 83 | 88 | { |
| 84 | 89 | $allowed = ['ASC', 'DESC']; |
| 85 | 90 | |
| 86 | - if(!isset($this->payload['order']) || !is_array($this->payload['order'])) |
|
| 87 | - return ''; |
|
| 91 | + if(!isset($this->payload['order']) || !is_array($this->payload['order'])) { |
|
| 92 | + return ''; |
|
| 93 | + } |
|
| 88 | 94 | |
| 89 | 95 | $orders = array(); |
| 90 | 96 | |
@@ -104,8 +110,9 @@ discard block |
||
| 104 | 110 | */ |
| 105 | 111 | public function getWhere() |
| 106 | 112 | { |
| 107 | - if(!is_array($this->payload['where'])) |
|
| 108 | - return []; |
|
| 113 | + if(!is_array($this->payload['where'])) { |
|
| 114 | + return []; |
|
| 115 | + } |
|
| 109 | 116 | |
| 110 | 117 | $adapter = new WhereAdapter(); |
| 111 | 118 | $where = $adapter->fromArray($this->payload['where']); |
@@ -52,8 +52,9 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | public function getProtectedColumns() |
| 54 | 54 | { |
| 55 | - if(is_null($this->protectedColumns)) |
|
| 56 | - $this->protectedColumns = []; |
|
| 55 | + if(is_null($this->protectedColumns)) { |
|
| 56 | + $this->protectedColumns = []; |
|
| 57 | + } |
|
| 57 | 58 | |
| 58 | 59 | return $this->protectedColumns; |
| 59 | 60 | } |
@@ -64,8 +64,9 @@ |
||
| 64 | 64 | call_user_func_array([$where, $method], $item); |
| 65 | 65 | } |
| 66 | 66 | if(is_string($item)){ |
| 67 | - if(in_array($item, $this->allowed)) |
|
| 68 | - call_user_func([$where, $item]); |
|
| 67 | + if(in_array($item, $this->allowed)) { |
|
| 68 | + call_user_func([$where, $item]); |
|
| 69 | + } |
|
| 69 | 70 | } |
| 70 | 71 | } |
| 71 | 72 | return $where; |