Completed
Push — master ( b279d0...f898d8 )
by Mehmet
03:31
created
src/Model.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace ModelUtils;
4 4
 
5
-class Model{
5
+class Model {
6 6
 
7
-    public $config_yaml ="";
7
+    public $config_yaml = "";
8 8
     public $schema = [];
9
-    public $type ="basic"; // ["basic","cache","search"]
9
+    public $type = "basic"; // ["basic","cache","search"]
10 10
     public $collection_name = "";
11 11
     public $data_file = null;
12 12
 
13
-    public function __construct(){
13
+    public function __construct() {
14 14
         $config = yaml_parse(trim($this->config_yaml));
15 15
         $this->schema = $config['schema'];
16 16
         $this->collection_name = $config['collection_name'];
@@ -19,48 +19,48 @@  discard block
 block discarded – undo
19 19
         var_dump($this->collection_name);
20 20
     }
21 21
 
22
-    public function validate($doc){
22
+    public function validate($doc) {
23 23
         return ModelUtils::validate_doc($this->schema, $doc);
24 24
     }
25 25
 
26
-    public function set_defaults($doc){
26
+    public function set_defaults($doc) {
27 27
         return ModelUtils::setting_model_defaults($this->schema, $doc);
28 28
     }
29 29
 
30 30
 
31
-    public function fit_doc($doc){
31
+    public function fit_doc($doc) {
32 32
         return ModelUtils::fit_doc_to_model($this->schema, $doc);
33 33
     }
34 34
 
35
-    public function install($db){
35
+    public function install($db) {
36 36
 
37 37
         $db->drop($this->collection_name, $this->schema);
38 38
         $db->create($this->collection_name, $this->schema);
39
-        $indexes =[];
40
-        foreach ($this->schema as $field=>$fconfig){
41
-            if($fconfig['_index']===true){
42
-                $index=['key'=>[$field=>1]];
43
-                if(isset($fconfig["_index_type"])){
44
-                    switch ($fconfig["_index_type"]){
39
+        $indexes = [];
40
+        foreach ($this->schema as $field=>$fconfig) {
41
+            if ($fconfig['_index'] === true) {
42
+                $index = ['key'=>[$field=>1]];
43
+                if (isset($fconfig["_index_type"])) {
44
+                    switch ($fconfig["_index_type"]) {
45 45
                         case 'unique':
46
-                            $index['unique']=true;
46
+                            $index['unique'] = true;
47 47
                             break;
48 48
                     }
49 49
                 }
50
-                $indexes[]=$index;
50
+                $indexes[] = $index;
51 51
             }
52 52
         }
53
-        if($this->data_file !== null){
54
-            if(file_exists(BASE_DIR.$this->data_file)){
55
-                $data = json_decode(file_get_contents(BASE_DIR.$this->data_file),true);
56
-                foreach ($data as $item){
53
+        if ($this->data_file !== null) {
54
+            if (file_exists(BASE_DIR.$this->data_file)) {
55
+                $data = json_decode(file_get_contents(BASE_DIR.$this->data_file), true);
56
+                foreach ($data as $item) {
57 57
                     $item = ModelUtils::setting_model_defaults($this->schema, $item);
58 58
                     $doc = ModelUtils::validate_doc($this->schema, $item);
59
-                    $db->insert($this->collection_name,$doc);
59
+                    $db->insert($this->collection_name, $doc);
60 60
                 }
61 61
             }
62 62
         }
63
-        if(count($indexes)>0){
63
+        if (count($indexes)>0) {
64 64
             $db->create_indexes($this->collection_name, $indexes);
65 65
         }
66 66
     }
Please login to merge, or discard this patch.
src/ModelUtils.php 2 patches
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
             // Does doc has a array that does not exist in model definition.
30 30
             if (!isset($my_model[$key])) {
31 31
                 if ($my_key !== null) {
32
-                    $my_key = strval($my_key) . "." . strval($key);
32
+                    $my_key = strval($my_key).".".strval($key);
33 33
                 } else {
34 34
                     $my_key = $key;
35 35
                 }
36
-                throw new \Exception("Error for key '" . $my_key . "' that does not exist in the model");
36
+                throw new \Exception("Error for key '".$my_key."' that does not exist in the model");
37 37
             }
38 38
             // Is the value of the array[key] again another array?.
39 39
             elseif (ModelUtils::gettype($my_doc[$key]) == "array") {
40 40
                 if ($my_key !== null) {
41
-                    $my_key = strval($my_key) . "." . strval($key);
41
+                    $my_key = strval($my_key).".".strval($key);
42 42
                 } else {
43 43
                     $my_key = $key;
44 44
                 }
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
             // Does the value of the array[key] have same variable type that stated in the definition of the model array.
52 52
             elseif (ModelUtils::gettype($my_doc[$key]) != $my_model[$key]['_type']) {
53 53
                 if ($my_key !== null) {
54
-                    $my_key = $my_key . "." . $key;
54
+                    $my_key = $my_key.".".$key;
55 55
                 } else {
56 56
                     $my_key = $key;
57 57
                 }
58
-                throw new \Exception("Error for key '" . $my_key . "'" . ", " . ModelUtils::gettype($my_doc[$key]) .
59
-                    " given but it must be " . $my_model[$key]['_type']);
58
+                throw new \Exception("Error for key '".$my_key."'".", ".ModelUtils::gettype($my_doc[$key]).
59
+                    " given but it must be ".$my_model[$key]['_type']);
60 60
             } else {
61 61
                 if ($my_key !== null) {
62
-                    $v_key = $my_key . "." . $key;
62
+                    $v_key = $my_key.".".$key;
63 63
                 } else {
64 64
                     $v_key = $key;
65 65
                 }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $my_keys = array_keys($my_doc);
82 82
         foreach ($my_keys as $key) {
83 83
             // If array has a key that is not presented in the model definition, unset it.
84
-            if (! isset($my_model[$key])) {
84
+            if (!isset($my_model[$key])) {
85 85
                 unset($my_doc[$key]);
86 86
             }
87 87
             // If array[$key] is again an array, recursively fit this array too.
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
                     return $my_doc[$key];
93 93
                 }
94 94
             }
95
-            elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] !="array") {
96
-                $my_doc[$key]=$my_model[$key]['_default'];
95
+            elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] != "array") {
96
+                $my_doc[$key] = $my_model[$key]['_default'];
97 97
             }
98 98
             // If array[key] is not an array and not has same variable type that stated in the model definition.
99 99
             else {
@@ -113,54 +113,54 @@  discard block
 block discarded – undo
113 113
     public static function setting_model_defaults($my_model, $my_doc)
114 114
     {
115 115
         $my_keys = array_keys($my_model);
116
-        $new_doc =[ ];
116
+        $new_doc = [];
117 117
         foreach ($my_keys as $key) {
118 118
             $item_keys = array_keys($my_model[$key]);
119 119
             // If one of the keys of $my_model[$key] is _type this is a definition, not a defined key
120 120
             if (in_array("_type", $item_keys)) {
121 121
                 // If array does not have this key, set the default value.
122
-                if (! isset($my_doc[$key])) {
123
-                    if(isset($my_model[$key]['_input_type'])){
124
-                        switch ($my_model[$key]['_input_type']){
122
+                if (!isset($my_doc[$key])) {
123
+                    if (isset($my_model[$key]['_input_type'])) {
124
+                        switch ($my_model[$key]['_input_type']) {
125 125
                             case 'uid':
126 126
                                     $shortid = ShortId::create();
127
-                                    $new_doc[$key]=$shortid->generate();
127
+                                    $new_doc[$key] = $shortid->generate();
128 128
                                 break;
129 129
                             case 'date':
130
-                                if($my_model[$key]['_default']=='today'){
130
+                                if ($my_model[$key]['_default'] == 'today') {
131 131
                                     $new_doc[$key] = date("Y-m-d");
132 132
                                 }
133
-                                else{
134
-                                    $new_doc[$key]=$my_model[$key]['_default'];
133
+                                else {
134
+                                    $new_doc[$key] = $my_model[$key]['_default'];
135 135
                                 }
136 136
                                 break;
137 137
                             case 'timestamp':
138
-                                if(($my_model[$key]['_default']=="now") && ($my_model[$key]['_type'] == "integer")){
138
+                                if (($my_model[$key]['_default'] == "now") && ($my_model[$key]['_type'] == "integer")) {
139 139
                                     $new_doc[$key] = time();
140 140
                                 }
141
-                                else if($my_model[$key]['_default']=="now" && ($my_model[$key]['_type']=="string")){
141
+                                else if ($my_model[$key]['_default'] == "now" && ($my_model[$key]['_type'] == "string")) {
142 142
                                     
143 143
                                     $new_doc[$key] = date("Y-m-d H:i:s");
144 144
                                 }
145
-                                else{
146
-                                    $new_doc[$key]=$my_model[$key]['_default'];
145
+                                else {
146
+                                    $new_doc[$key] = $my_model[$key]['_default'];
147 147
                                 }
148 148
                                 break;
149 149
                     
150 150
                             default:
151
-                                $new_doc[$key]=$my_model[$key]['_default'];
151
+                                $new_doc[$key] = $my_model[$key]['_default'];
152 152
                         }
153 153
                     }
154
-                    else{
155
-                        $new_doc[$key]=$my_model[$key]['_default'];
154
+                    else {
155
+                        $new_doc[$key] = $my_model[$key]['_default'];
156 156
                     }
157 157
                 }                
158 158
                 // If array has this key
159 159
                 else {
160 160
                     // If model definition stated this key's default value is not Null and has a wrong variable type, fix it.
161 161
                     if ($my_model[$key]['_default'] !== null) {
162
-                        if(ModelUtils::gettype($my_doc[$key]) != $my_model[$key]['_type'] && ModelUtils::gettype($my_doc[$key]) == "array"){
163
-                            $my_doc[$key]=$my_model[$key]['_default'];
162
+                        if (ModelUtils::gettype($my_doc[$key]) != $my_model[$key]['_type'] && ModelUtils::gettype($my_doc[$key]) == "array") {
163
+                            $my_doc[$key] = $my_model[$key]['_default'];
164 164
                         }
165 165
                         settype($my_doc[$key], $my_model[$key]['_type']);
166 166
                     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             }            
171 171
             // If one of the keys is not _type, this is a defined key, recursively get sub keys.
172 172
             else {
173
-                if (! isset($my_doc[$key])) {
173
+                if (!isset($my_doc[$key])) {
174 174
                     $my_doc[$key] = "";
175 175
                 }
176 176
                 $new_doc[$key] = ModelUtils::setting_model_defaults($my_model[$key], $my_doc[$key]);
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public static function validate_doc_item($value, $my_model, $key)
191 191
     {
192
-        $type        = isset($my_model['_type'])         ? $my_model['_type']         : 'string';
193
-        $input_type  = isset($my_model['_input_type'])   ? $my_model['_input_type']   : 'string';
192
+        $type        = isset($my_model['_type']) ? $my_model['_type'] : 'string';
193
+        $input_type  = isset($my_model['_input_type']) ? $my_model['_input_type'] : 'string';
194 194
         $format      = isset($my_model['_input_format']) ? $my_model['_input_format'] : "";
195
-        $min_length  = isset($my_model['_min_length'])   ? $my_model['_min_length']   : null;
196
-        $max_length  = isset($my_model['_max_length'])   ? $my_model['_max_length']   : null;
197
-        $in_options  = isset($my_model['_in_options'])   ? $my_model['_in_options']   : null;
195
+        $min_length  = isset($my_model['_min_length']) ? $my_model['_min_length'] : null;
196
+        $max_length  = isset($my_model['_max_length']) ? $my_model['_max_length'] : null;
197
+        $in_options  = isset($my_model['_in_options']) ? $my_model['_in_options'] : null;
198 198
 
199 199
         if (ModelUtils::gettype($value) != $type) {
200 200
             return false;
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
                 case 'mail':
206 206
                     $filter_check = filter_var($value, FILTER_VALIDATE_EMAIL);
207 207
                     if ($filter_check === false) {
208
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
208
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
209 209
                             "validation: INVALID_EMAIL_ADDRESS ");
210 210
                     }
211 211
                     break;
212 212
                 case 'bool':
213 213
                     $filter_check = filter_var($value, FILTER_VALIDATE_BOOLEAN);
214 214
                     if ($filter_check === false) {
215
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
215
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
216 216
                             "validation: INVALID_BOOLEAN_VALUE ");
217 217
                     }
218 218
                     break;
219 219
                 case 'url':
220 220
                     $filter_check = filter_var($value, FILTER_VALIDATE_URL);
221 221
                     if ($filter_check === false) {
222
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
222
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
223 223
                             "validation: INVALID_URL ");
224 224
                     }
225 225
                     break;
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
                 case 'ip':
230 230
                     $filter_check = filter_var($value, FILTER_VALIDATE_IP);
231 231
                     if ($filter_check === false) {
232
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
232
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
233 233
                             "validation: INVALID_IP_ADDRESS ");
234 234
                     }
235 235
                     break;
236 236
                 case 'mac_address':
237 237
                     $filter_check = filter_var($value, FILTER_VALIDATE_MAC);
238 238
                     if ($filter_check === false) {
239
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
239
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
240 240
                             "validation: INVALID_MAC_ADDRESS ");
241 241
                     }
242 242
                     break;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                     $regex        = "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/";
245 245
                     $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex)));
246 246
                     if ($filter_check === false) {
247
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
247
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
248 248
                             "validation: INVALID_FORMAT ");
249 249
                     }
250 250
                     break;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                     $regex        = "/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])$/";
253 253
                     $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex)));
254 254
                     if ($filter_check === false) {
255
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
255
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
256 256
                             "validation: INVALID_FORMAT ");
257 257
                     }
258 258
                     break;
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
                     $regex        = "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) ([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])$/";
261 261
                     $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex)));
262 262
                     if ($filter_check === false) {
263
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the validation: INVALID_FORMAT ");
263
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the validation: INVALID_FORMAT ");
264 264
                     }
265 265
                     break;
266 266
                 case 'regex':
267 267
                     $regex        = "/^".$format."$/";
268 268
                     $filter_check = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=> $regex)));
269 269
                     if ($filter_check === false) {
270
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
270
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
271 271
                             "validation: INVALID_FORMAT ");
272 272
                     }
273 273
                     break;
@@ -277,28 +277,28 @@  discard block
 block discarded – undo
277 277
             case 'integer':
278 278
             case 'float':
279 279
                 if ($min_length !== null) {
280
-                    if ($value < $min_length) {
281
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
280
+                    if ($value<$min_length) {
281
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
282 282
                             "validation: Must be bigger than ".$min_length."  ");
283 283
                     }
284 284
                 }
285 285
                 if ($max_length !== null) {
286
-                    if ($value > $max_length) {
287
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
286
+                    if ($value>$max_length) {
287
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
288 288
                             "validation: Must be smallerr than ".$max_length."  ");
289 289
                     }
290 290
                 }
291 291
                 break;
292 292
             default:
293 293
                 if ($max_length !== null) {
294
-                    if (strlen($value) > $max_length) {
295
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
294
+                    if (strlen($value)>$max_length) {
295
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
296 296
                             "validation: It's length must be smaller than ".$max_length."  ");
297 297
                     }
298 298
                 }
299 299
                 if ($min_length !== null) {
300
-                    if (strlen($value) < $min_length) {
301
-                        throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the ".
300
+                    if (strlen($value)<$min_length) {
301
+                        throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the ".
302 302
                             "validation: It's length must be longer than ".$min_length."  ");
303 303
                     }
304 304
                 }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         }
307 307
         if ($in_options !== null) {
308 308
             if (!in_array($value, $in_options)) {
309
-                throw new \Exception("Error for value '" . $value . "' for '".$key."' couldn't pass the validation: ".
309
+                throw new \Exception("Error for value '".$value."' for '".$key."' couldn't pass the validation: ".
310 310
                     "It's length must be one of the these values: ".implode(",", $in_options)."  ");
311 311
             }
312 312
         }
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public static function sanitize_doc_item($value, $my_model)
324 324
     {
325
-        $type        = isset($my_model['_type'])         ? $my_model['_type']         : 'string';
326
-        $input_type  = isset($my_model['_input_type'])   ? $my_model['_input_type']   : null;
325
+        $type        = isset($my_model['_type']) ? $my_model['_type'] : 'string';
326
+        $input_type  = isset($my_model['_input_type']) ? $my_model['_input_type'] : null;
327 327
         $format      = isset($my_model['_input_format']) ? $my_model['_input_format'] : "";
328
-        $min_length  = isset($my_model['_min_length'])   ? $my_model['_min_length']   : null;
329
-        $max_length  = isset($my_model['_max_length'])   ? $my_model['_max_length']   : null;
330
-        $in_options  = isset($my_model['_in_options'])   ? $my_model['_in_options']   : null;
328
+        $min_length  = isset($my_model['_min_length']) ? $my_model['_min_length'] : null;
329
+        $max_length  = isset($my_model['_max_length']) ? $my_model['_max_length'] : null;
330
+        $in_options  = isset($my_model['_in_options']) ? $my_model['_in_options'] : null;
331 331
 
332 332
         if ($input_type !== null) {
333 333
             switch ($input_type) {
334 334
                 case 'mail':
335
-                    $value= filter_var($value, FILTER_SANITIZE_EMAIL);
335
+                    $value = filter_var($value, FILTER_SANITIZE_EMAIL);
336 336
                     break;
337 337
                 case 'timestamp':
338
-                    if ($value=='now') {
338
+                    if ($value == 'now') {
339 339
                         $value = time();
340 340
                     }
341 341
                     break;
@@ -380,19 +380,19 @@  discard block
 block discarded – undo
380 380
             case 'integer':
381 381
             case 'float':
382 382
                 if ($min_length !== null) {
383
-                    if ($value < $min_length) {
383
+                    if ($value<$min_length) {
384 384
                         $value = $min_length;
385 385
                     }
386 386
                 }
387 387
                 if ($max_length !== null) {
388
-                    if ($value > $max_length) {
388
+                    if ($value>$max_length) {
389 389
                         $value = $max_length;
390 390
                     }
391 391
                 }
392 392
                 break;
393 393
             default:
394 394
                 if ($max_length !== null) {
395
-                    if (strlen($value) > $max_length) {
395
+                    if (strlen($value)>$max_length) {
396 396
                         $value = substr($value, 0, $max_length);
397 397
                     }
398 398
                 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
                 if (ModelUtils::gettype($my_doc[$key]) != "array") {
92 92
                     return $my_doc[$key];
93 93
                 }
94
-            }
95
-            elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] !="array") {
94
+            } elseif (ModelUtils::gettype($my_doc[$key]) == "array" && $my_model[$key]['_type'] !="array") {
96 95
                 $my_doc[$key]=$my_model[$key]['_default'];
97 96
             }
98 97
             // If array[key] is not an array and not has same variable type that stated in the model definition.
@@ -129,20 +128,17 @@  discard block
 block discarded – undo
129 128
                             case 'date':
130 129
                                 if($my_model[$key]['_default']=='today'){
131 130
                                     $new_doc[$key] = date("Y-m-d");
132
-                                }
133
-                                else{
131
+                                } else{
134 132
                                     $new_doc[$key]=$my_model[$key]['_default'];
135 133
                                 }
136 134
                                 break;
137 135
                             case 'timestamp':
138 136
                                 if(($my_model[$key]['_default']=="now") && ($my_model[$key]['_type'] == "integer")){
139 137
                                     $new_doc[$key] = time();
140
-                                }
141
-                                else if($my_model[$key]['_default']=="now" && ($my_model[$key]['_type']=="string")){
138
+                                } else if($my_model[$key]['_default']=="now" && ($my_model[$key]['_type']=="string")){
142 139
                                     
143 140
                                     $new_doc[$key] = date("Y-m-d H:i:s");
144
-                                }
145
-                                else{
141
+                                } else{
146 142
                                     $new_doc[$key]=$my_model[$key]['_default'];
147 143
                                 }
148 144
                                 break;
@@ -150,8 +146,7 @@  discard block
 block discarded – undo
150 146
                             default:
151 147
                                 $new_doc[$key]=$my_model[$key]['_default'];
152 148
                         }
153
-                    }
154
-                    else{
149
+                    } else{
155 150
                         $new_doc[$key]=$my_model[$key]['_default'];
156 151
                     }
157 152
                 }                
Please login to merge, or discard this patch.