@@ -59,18 +59,18 @@ |
||
59 | 59 | { |
60 | 60 | $where = new Where(); |
61 | 61 | |
62 | - foreach($jWhere as $item){ |
|
63 | - if(is_array($item)){ |
|
64 | - if(!in_array($item[0], $this->allowed)) { |
|
62 | + foreach ($jWhere as $item) { |
|
63 | + if (is_array($item)) { |
|
64 | + if (!in_array($item[0], $this->allowed)) { |
|
65 | 65 | throw new InvalidCommandException(); |
66 | 66 | } |
67 | 67 | $method = $item[0]; |
68 | 68 | unset($item[0]); |
69 | 69 | $where = call_user_func_array([$where, $method], $item); |
70 | 70 | } |
71 | - if(is_string($item)){ |
|
72 | - if(in_array($item, $this->allowed)) |
|
73 | - if($item == 'and') |
|
71 | + if (is_string($item)) { |
|
72 | + if (in_array($item, $this->allowed)) |
|
73 | + if ($item == 'and') |
|
74 | 74 | $where = $where->and; |
75 | 75 | else if ($item == 'or') |
76 | 76 | $where = $where->or; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getProtectedColumns() |
54 | 54 | { |
55 | - if(is_null($this->protectedColumns)) |
|
55 | + if (is_null($this->protectedColumns)) |
|
56 | 56 | $this->protectedColumns = []; |
57 | 57 | |
58 | 58 | return $this->protectedColumns; |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | // Adapta o payload ao padrão do zend |
81 | 81 | $select = new Select(); |
82 | 82 | |
83 | - if(!is_null($this->getSelectPayload()->getOrder())) |
|
83 | + if (!is_null($this->getSelectPayload()->getOrder())) |
|
84 | 84 | $select->order($this->getSelectPayload()->getOrder()); |
85 | 85 | |
86 | 86 | $select->columns($columns); |
87 | 87 | $select->where($this->getSelectPayload()->getWhere()); |
88 | 88 | |
89 | 89 | $limit = $this->getSelectPayload()->getLimit(); |
90 | - if(!empty($limit)) |
|
90 | + if (!empty($limit)) |
|
91 | 91 | $select->limit($this->getSelectPayload()->getLimit()); |
92 | 92 | |
93 | 93 | $offset = $this->getSelectPayload()->getOffset(); |
94 | - if(!empty($offset)) |
|
94 | + if (!empty($offset)) |
|
95 | 95 | $select->offset($this->getSelectPayload()->getOffset()); |
96 | 96 | |
97 | 97 | return $select; |
@@ -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 500; |
70 | 70 | |
71 | - if(!is_numeric($this->payload['limit'])) |
|
71 | + if (!is_numeric($this->payload['limit'])) |
|
72 | 72 | return 500; |
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 null; |
86 | 86 | |
87 | - if(!is_numeric($this->payload['offset'])) |
|
87 | + if (!is_numeric($this->payload['offset'])) |
|
88 | 88 | return null; |
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(); |