@@ -38,21 +38,21 @@ 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'])) |
|
| 41 | + if (!isset($this->payload['columns']) || !is_array($this->payload['columns'])) |
|
| 42 | 42 | return ['*']; |
| 43 | 43 | |
| 44 | 44 | $regex = '/^[a-zA-Z_][a-zA-Z0-9_]*$/'; |
| 45 | 45 | $columns = array(); |
| 46 | 46 | |
| 47 | - foreach ($this->payload['columns'] as $column){ |
|
| 47 | + foreach ($this->payload['columns'] as $column) { |
|
| 48 | 48 | // Valida o nome da coluna |
| 49 | - if(!is_string($column) || !preg_match($regex, $column)) |
|
| 49 | + if (!is_string($column) || !preg_match($regex, $column)) |
|
| 50 | 50 | throw new InvalidColumnNameException(); |
| 51 | 51 | |
| 52 | 52 | $columns[] = $column; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if(count($columns) == 0) |
|
| 55 | + if (count($columns) == 0) |
|
| 56 | 56 | return ['*']; |
| 57 | 57 | |
| 58 | 58 | return $columns; |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function getLimit() |
| 67 | 67 | { |
| 68 | - if(!isset($this->payload['limit'])) |
|
| 68 | + if (!isset($this->payload['limit'])) |
|
| 69 | 69 | return null; |
| 70 | 70 | |
| 71 | - if(!is_numeric($this->payload['limit'])) |
|
| 71 | + if (!is_numeric($this->payload['limit'])) |
|
| 72 | 72 | return null; |
| 73 | 73 | |
| 74 | 74 | return (int) $this->payload['limit']; |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function getOffset() |
| 83 | 83 | { |
| 84 | - if(!isset($this->payload['offset'])) |
|
| 84 | + if (!isset($this->payload['offset'])) |
|
| 85 | 85 | return 1; |
| 86 | 86 | |
| 87 | - if(!is_numeric($this->payload['offset'])) |
|
| 87 | + if (!is_numeric($this->payload['offset'])) |
|
| 88 | 88 | return 1; |
| 89 | 89 | |
| 90 | 90 | return (int) $this->payload['offset']; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $allowed = ['ASC', 'DESC']; |
| 101 | 101 | |
| 102 | - if(!isset($this->payload['order']) || !is_array($this->payload['order'])) |
|
| 102 | + if (!isset($this->payload['order']) || !is_array($this->payload['order'])) |
|
| 103 | 103 | return null; |
| 104 | 104 | |
| 105 | 105 | $orders = array(); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getWhere() |
| 123 | 123 | { |
| 124 | - if(!is_array($this->payload['where'])) |
|
| 124 | + if (!is_array($this->payload['where'])) |
|
| 125 | 125 | return []; |
| 126 | 126 | |
| 127 | 127 | $adapter = new WhereAdapter(); |
@@ -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_numeric($this->payload['limit'])) |
|
| 72 | - return null; |
|
| 75 | + if(!is_numeric($this->payload['limit'])) { |
|
| 76 | + return null; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | 79 | return (int) $this->payload['limit']; |
| 75 | 80 | } |
@@ -81,11 +86,13 @@ discard block |
||
| 81 | 86 | */ |
| 82 | 87 | public function getOffset() |
| 83 | 88 | { |
| 84 | - if(!isset($this->payload['offset'])) |
|
| 85 | - return 1; |
|
| 89 | + if(!isset($this->payload['offset'])) { |
|
| 90 | + return 1; |
|
| 91 | + } |
|
| 86 | 92 | |
| 87 | - if(!is_numeric($this->payload['offset'])) |
|
| 88 | - return 1; |
|
| 93 | + if(!is_numeric($this->payload['offset'])) { |
|
| 94 | + return 1; |
|
| 95 | + } |
|
| 89 | 96 | |
| 90 | 97 | return (int) $this->payload['offset']; |
| 91 | 98 | } |
@@ -99,8 +106,9 @@ discard block |
||
| 99 | 106 | { |
| 100 | 107 | $allowed = ['ASC', 'DESC']; |
| 101 | 108 | |
| 102 | - if(!isset($this->payload['order']) || !is_array($this->payload['order'])) |
|
| 103 | - return null; |
|
| 109 | + if(!isset($this->payload['order']) || !is_array($this->payload['order'])) { |
|
| 110 | + return null; |
|
| 111 | + } |
|
| 104 | 112 | |
| 105 | 113 | $orders = array(); |
| 106 | 114 | |
@@ -121,8 +129,9 @@ discard block |
||
| 121 | 129 | */ |
| 122 | 130 | public function getWhere() |
| 123 | 131 | { |
| 124 | - if(!is_array($this->payload['where'])) |
|
| 125 | - return []; |
|
| 132 | + if(!is_array($this->payload['where'])) { |
|
| 133 | + return []; |
|
| 134 | + } |
|
| 126 | 135 | |
| 127 | 136 | $adapter = new WhereAdapter(); |
| 128 | 137 | $where = $adapter->fromArray($this->payload['where']); |