Passed
Push — main ( 70a409...534b00 )
by Wagner
01:22
created
source/Api/Products.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $params = "";
34 34
         $values = $this->headers;
35 35
         
36
-        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) {
36
+        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) {
37 37
             $this->call(
38 38
                 400,
39 39
                 "invalid_data",
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
             )->back();
42 42
             return;
43 43
         }
44
-        $category_id = explode('&',$_SERVER['REQUEST_URI']);
44
+        $category_id = explode('&', $_SERVER['REQUEST_URI']);
45 45
         
46 46
         if (!empty($category_id) && count($category_id) == 2) {
47
-            $category = explode('=',$category_id[1]);
48
-            if($category[0] == 'category_id'){
47
+            $category = explode('=', $category_id[1]);
48
+            if ($category[0] == 'category_id') {
49 49
                 $category_id = filter_var($category[1], FILTER_VALIDATE_INT);
50 50
                 $where  = " AND category_id=:category_id";
51 51
                 $params = "&category_id={$category_id}";
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
 
55 55
         //get products
56
-        $products = (new Product())->find("restaurant_id=:restaurant_id{$where}","restaurant_id={$restaurant_id}{$params}");
56
+        $products = (new Product())->find("restaurant_id=:restaurant_id{$where}", "restaurant_id={$restaurant_id}{$params}");
57 57
         
58 58
         if (!$products->count()) {
59 59
             $this->call(
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             return;
92 92
         }
93 93
 
94
-        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) {
94
+        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) {
95 95
             $this->call(
96 96
                 400,
97 97
                 "invalid_data",
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
             return;
112 112
         }
113 113
 
114
-        if ( empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"]) ) {
114
+        if (empty($data["category_id"]) || !$category_id = filter_var($data["category_id"], FILTER_VALIDATE_INT) || empty($data["name"]) || empty($data["price"])) {
115 115
             $this->call(
116 116
                 400,
117 117
                 "empty_data",
118 118
                 "Para criar informe o ID da categoria do produto, o nome do produto e o preço do produto"
119 119
             )->back();
120
-            return ;
120
+            return;
121 121
         }
122 122
 
123 123
         $category = (new ProductCategory())->findById($category_id);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : 0.00;
142 142
         $product->save();
143 143
 
144
-        if($product->fail()){
144
+        if ($product->fail()) {
145 145
             $this->call(
146 146
                 400,
147 147
                 "empty_data",
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function read(array $data): void
161 161
     {
162
-        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT) ) {
162
+        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) {
163 163
             $this->call(
164 164
                 400,
165 165
                 "invalid_data",
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         }
170 170
 
171 171
         
172
-        if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) {
172
+        if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) {
173 173
             $this->call(
174 174
                 400,
175 175
                 "invalid_data",
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function update(array $data): void
202 202
     {
203
-        if ( empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) {
203
+        if (empty($data["restaurant_id"]) || !$restaurant_id = filter_var($data["restaurant_id"], FILTER_VALIDATE_INT)) {
204 204
             $this->call(
205 205
                 400,
206 206
                 "invalid_data",
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             return;
210 210
         }
211 211
 
212
-        if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) {
212
+        if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) {
213 213
             $this->call(
214 214
                 400,
215 215
                 "invalid_data",
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $product->old_price = (!empty($data["old_price"])) ? filter_var($data["old_price"], FILTER_SANITIZE_STRIPPED) : $product->old_price;
238 238
         $product->save();
239 239
 
240
-        if($product->fail()){
240
+        if ($product->fail()) {
241 241
             $this->call(
242 242
                 400,
243 243
                 "empty_data",
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             return;
265 265
         }
266 266
 
267
-        if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT) ) {
267
+        if (empty($data["product_id"]) || !$product_id = filter_var($data["product_id"], FILTER_VALIDATE_INT)) {
268 268
             $this->call(
269 269
                 400,
270 270
                 "invalid_data",
Please login to merge, or discard this patch.