Code Duplication    Length = 27-28 lines in 2 locations

src/Http/Api/IssueController.php 2 locations

@@ 1231-1258 (lines=28) @@
1228
1229
                foreach ($after_data as $key => $val)
1230
                {
1231
                    if (!isset($before_data[$key]) || $val !== $before_data[$key]) {
1232
                        $tmp = [];
1233
                        $tmp['field'] = isset($val['name']) ? $val['name'] : '';
1234
                        $tmp['after_value'] = isset($val['value']) ? $val['value'] : '';
1235
                        $tmp['before_value'] = isset($before_data[$key]) && isset($before_data[$key]['value']) ? $before_data[$key]['value'] : '';
1236
1237
                        if (is_array($tmp['after_value']) && is_array($tmp['before_value'])) {
1238
                            $diff1 = array_diff($tmp['after_value'], $tmp['before_value']);
1239
                            $diff2 = array_diff($tmp['before_value'], $tmp['after_value']);
1240
                            $tmp['after_value'] = implode(',', $diff1);
1241
                            $tmp['before_value'] = implode(',', $diff2);
1242
                        }
1243
                        else
1244
                        {
1245
                            if (is_array($tmp['after_value'])) {
1246
                                $tmp['after_value'] = implode(',', $tmp['after_value']);
1247
                            }
1248
                            if (is_array($tmp['before_value'])) {
1249
                                $tmp['before_value'] = implode(',', $tmp['before_value']);
1250
                            }
1251
                        }
1252
                        $diff_items[] = $tmp; 
1253
                        $diff_keys[] = $key; 
1254
                    }
1255
                }
1256
1257
                foreach ($before_data as $key => $val)
1258
                {
1259
                    if (array_search($key, $diff_keys) !== false) {
1260
                        continue;
1261
                    }
@@ 1263-1289 (lines=27) @@
1260
                        continue;
1261
                    }
1262
1263
                    if (!isset($after_data[$key]) || $val !== $after_data[$key]) {
1264
                        $tmp = [];
1265
                        $tmp['field'] = isset($val['name']) ? $val['name'] : '';
1266
                        $tmp['before_value'] = isset($val['value']) ? $val['value'] : '';
1267
                        $tmp['after_value'] = isset($after_data[$key]) && isset($after_data[$key]['value']) ? $after_data[$key]['value'] : '';
1268
                        if (is_array($tmp['after_value']) && is_array($tmp['before_value'])) {
1269
                            $diff1 = array_diff($tmp['after_value'], $tmp['before_value']);
1270
                            $diff2 = array_diff($tmp['before_value'], $tmp['after_value']);
1271
                            $tmp['after_value'] = implode(',', $diff1);
1272
                            $tmp['before_value'] = implode(',', $diff2);
1273
                        }
1274
                        else
1275
                        {
1276
                            if (is_array($tmp['after_value'])) {
1277
                                $tmp['after_value'] = implode(',', $tmp['after_value']);
1278
                            }
1279
                            if (is_array($tmp['before_value'])) {
1280
                                $tmp['before_value'] = implode(',', $tmp['before_value']);
1281
                            }
1282
                        }
1283
1284
                        $diff_items[] = $tmp; 
1285
                    }
1286
                }
1287
1288
                if ($diff_items) {
1289
                    $changed_items['data'] = $diff_items;
1290
                    $changedRecords[] = $changed_items;
1291
                }
1292
            }