Code Duplication    Length = 23-24 lines in 2 locations

src/TradeDoublerEx.php 2 locations

@@ 22-44 (lines=23) @@
19
        $insertedTransactions= self::getTransactionListByDateType($merchantList, $dStartDate, $dEndDate, false);
20
21
        $parsedIDs=[];
22
        foreach ($insertedTransactions as $transaction){
23
            if (array_key_exists('unique_id', $transaction)){
24
                $found=false;
25
                for ($i=0;$i<count($totalTransactions);$i++){
26
                    // Check also event_id to obtain a real unique key - <PN> - 2017-07-03
27
                    if ($totalTransactions[$i]['unique_id']==$transaction['unique_id'] && $totalTransactions[$i]['event_id']==$transaction['event_id']){
28
                        if ($totalTransactions[$i]['commission']<=0){
29
                            $totalTransactions[$i] = $transaction;
30
                            $found=true;
31
                            break;
32
                        }
33
                        if ($totalTransactions[$i]['status']==\Oara\Utilities::STATUS_DECLINED){
34
                            $totalTransactions[$i] = $transaction;
35
                            $found=true;
36
                            break;
37
                        }
38
                    }
39
                }
40
                if (!$found){
41
                    $totalTransactions[] = $transaction;
42
                }
43
            }
44
        }
45
        foreach ($updatedTransactions as $transaction){
46
            if (array_key_exists('unique_id',$transaction)){
47
                $found=false;
@@ 45-68 (lines=24) @@
42
                }
43
            }
44
        }
45
        foreach ($updatedTransactions as $transaction){
46
            if (array_key_exists('unique_id',$transaction)){
47
                $found=false;
48
                for ($i=0;$i<count($totalTransactions);$i++){
49
                    // Check also event_id to obtain a real unique key - <PN> - 2017-07-03
50
                    if ($totalTransactions[$i]['unique_id']==$transaction['unique_id'] && $totalTransactions[$i]['event_id']==$transaction['event_id']){
51
                        if ($totalTransactions[$i]['commission']<=0){
52
                            $totalTransactions[$i]=$transaction;
53
                            $found=true;
54
                            break;
55
                        }
56
                        if ($totalTransactions[$i]['status']==\Oara\Utilities::STATUS_DECLINED){
57
                            $totalTransactions[$i]=$transaction;
58
                            $found=true;
59
                            break;
60
                        }
61
62
                    }
63
                }
64
                if (!$found){
65
                    $totalTransactions[]=$transaction;
66
                }
67
            }
68
        }
69
        return $totalTransactions;
70
    }
71