@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace HnrAzevedo\Datamanager; |
4 | 4 | |
5 | -trait DataTrait{ |
|
5 | +trait DataTrait { |
|
6 | 6 | use CrudTrait, CheckTrait; |
7 | 7 | |
8 | 8 | protected ?string $table = null; |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | protected function mountRemove(): array |
25 | 25 | { |
26 | 26 | $return = ['data' => '', 'where' => '']; |
27 | - foreach($this->where as $clause => $condition){ |
|
28 | - if(strlen($clause) === 0){ |
|
27 | + foreach ($this->where as $clause => $condition) { |
|
28 | + if (strlen($clause) === 0) { |
|
29 | 29 | $return['where'] .= " {$clause} {$condition[0]} {$condition[1]} :q_{$condition[0]} "; |
30 | 30 | $return['data'] .= "q_{$condition[0]}={$condition[2]}&"; |
31 | 31 | continue; |
32 | 32 | } |
33 | 33 | |
34 | - foreach($condition as $value){ |
|
34 | + foreach ($condition as $value) { |
|
35 | 35 | $return['where'] .= " {$clause} {$value[0]} {$value[1]} :q_{$value[0]} "; |
36 | 36 | $return['data'] .= "q_{$value[0]}={$value[2]}&"; |
37 | 37 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $return = ['data' => []]; |
45 | 45 | |
46 | 46 | foreach ($this->data as $key => $value) { |
47 | - if($this->upgradeable($key) && !$this->isIncremented($key)){ |
|
47 | + if ($this->upgradeable($key) && !$this->isIncremented($key)) { |
|
48 | 48 | $return['data'][$key] = $this->data[$key]['value']; |
49 | 49 | } |
50 | 50 | } |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | |
60 | 60 | $key = (!$key) ? '' : " {$key} "; |
61 | 61 | |
62 | - if(is_array($value[0])){ |
|
62 | + if (is_array($value[0])) { |
|
63 | 63 | |
64 | - if(is_array($value[0][2])){ |
|
64 | + if (is_array($value[0][2])) { |
|
65 | 65 | $where = ''; |
66 | 66 | |
67 | - foreach($value[0][2] as $v => $valu){ |
|
67 | + foreach ($value[0][2] as $v => $valu) { |
|
68 | 68 | $where .= " :q_{$value[0][0]}_{$v},"; |
69 | 69 | $return['data']["q_{$value[0][0]}_{$v}"] = $valu; |
70 | 70 | } |
71 | 71 | |
72 | - $where = substr($where,0,-1); |
|
72 | + $where = substr($where, 0, -1); |
|
73 | 73 | $return['where'] .= " {$key} {$value[0][0]} {$value[0][1]} ($where) "; |
74 | 74 | |
75 | 75 | continue; |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | { |
92 | 92 | $return = ['where' => '', 'data' => []]; |
93 | 93 | |
94 | - foreach($this->between as $field => $value){ |
|
95 | - $condition = (count(explode(' ',$field)) > 2) ? ' '.explode(' ',$field)[0].' ' : ' AND '; |
|
96 | - $field = str_replace(['AND','OR',' '],'',$field); |
|
94 | + foreach ($this->between as $field => $value) { |
|
95 | + $condition = (count(explode(' ', $field)) > 2) ? ' '.explode(' ', $field)[0].' ' : ' AND '; |
|
96 | + $field = str_replace(['AND', 'OR', ' '], '', $field); |
|
97 | 97 | $return['where'] .= " {$condition} {$field} BETWEEN :q_1{$field} AND :q_2{$field} "; |
98 | 98 | $return['data'] = [ |
99 | - "q_1{$field}" => (date_format( date_create_from_format(DATAMANAGER_CONFIG['dateformat'],$value[0]) , 'Y-m-d')), |
|
100 | - "q_2{$field}" => (date_format( date_create_from_format(DATAMANAGER_CONFIG['dateformat'],$value[1]) , 'Y-m-d')) |
|
99 | + "q_1{$field}" => (date_format(date_create_from_format(DATAMANAGER_CONFIG['dateformat'], $value[0]), 'Y-m-d')), |
|
100 | + "q_2{$field}" => (date_format(date_create_from_format(DATAMANAGER_CONFIG['dateformat'], $value[1]), 'Y-m-d')) |
|
101 | 101 | ]; |
102 | 102 | } |
103 | 103 | return $return; |
@@ -105,21 +105,21 @@ discard block |
||
105 | 105 | |
106 | 106 | protected function mountSelect() |
107 | 107 | { |
108 | - $select = implode(',',array_keys($this->select)); |
|
108 | + $select = implode(',', array_keys($this->select)); |
|
109 | 109 | |
110 | - $this->query = str_replace('*', $select,$this->query); |
|
110 | + $this->query = str_replace('*', $select, $this->query); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | protected function mountLimit() |
114 | 114 | { |
115 | - if(!is_null($this->limit)){ |
|
115 | + if (!is_null($this->limit)) { |
|
116 | 116 | $this->query .= " LIMIT {$this->limit}"; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | protected function mountOffset() |
121 | 121 | { |
122 | - if(!is_null($this->offset)){ |
|
122 | + if (!is_null($this->offset)) { |
|
123 | 123 | $this->query .= " OFFSET {$this->offset}"; |
124 | 124 | } |
125 | 125 | } |