Code Duplication    Length = 32-32 lines in 2 locations

src/plugins/onTick/siphons.php 2 locations

@@ 109-140 (lines=32) @@
106
            $rawGoo = array(16634, 16643, 16647, 16641, 16640, 16635, 16648, 16633, 16646, 16651, 16650, 16644, 16652, 16639, 16636, 16649, 16653, 16638, 16637, 16642);
107
            foreach ($xml->result->rowset->row as $structures) {
108
                //Check silos
109
                if ($structures->attributes()->typeID == 14343) {
110
                    if (isset($structures->rowset->row)) {
111
                        foreach ($structures->rowset->row as $silo) {
112
                            //Avoid reporting empty silos
113
                            if ($silo->attributes()->quantity != 0 && in_array($silo->attributes()->typeID, $rawGoo)) {
114
                                $siloID = $structures->attributes()->itemID;
115
                                $lastAmount = getPermCache("silo{$siloID}Amount");
116
                                $gooAmount = $silo->attributes()->quantity;
117
                                $gooDifference = $gooAmount - $lastAmount;
118
                                //Check if silo has been checked before
119
                                if(!isset($lastAmount) || $gooDifference < 0){
120
                                    setPermCache("silo{$siloID}Amount", $gooAmount);
121
                                    continue;
122
                                }
123
                                //Check for a multiple of 50 in the difference
124
                                if ($gooDifference % 50 != 0) {
125
                                    $gooType = apiTypeName($silo->attributes()->typeID);
126
                                    $systemName = apiCharacterName($structures->attributes()->locationID);
127
                                    $msg = "{$siphonCorp["prefix"]}";
128
                                    $msg .= "**POSSIBLE SIPHON**\n";
129
                                    $msg .= "**System: **{$systemName} has a possible siphon stealing {$gooType} from a silo.\n";
130
                                    // Queue the message
131
                                    priorityQueueMessage($msg, $siphonCorp["channelID"], $this->guild);
132
                                    $this->logger->addInfo("Siphons: {$msg}");
133
                                    setPermCache("silo{$siloID}Amount", $gooAmount);
134
                                } else {
135
                                    setPermCache("silo{$siloID}Amount", $gooAmount);
136
                                }
137
                            }
138
                        }
139
                    }
140
                }
141
                if ($structures->attributes()->typeID == 17982) {
142
                    if (isset($structures->rowset->row)) {
143
                        foreach ($structures->rowset->row as $coupling) {
@@ 141-172 (lines=32) @@
138
                        }
139
                    }
140
                }
141
                if ($structures->attributes()->typeID == 17982) {
142
                    if (isset($structures->rowset->row)) {
143
                        foreach ($structures->rowset->row as $coupling) {
144
                            //Avoid reporting empty coupling arrays
145
                            if ($coupling->attributes()->quantity != 0 && in_array($coupling->attributes()->typeID, $rawGoo)) {
146
                                $couplingID = $structures->attributes()->itemID;
147
                                $lastAmount = getPermCache("couplingArray{$couplingID}Amount");
148
                                $gooAmount = $coupling->attributes()->quantity;
149
                                $gooDifference = $gooAmount - $lastAmount;
150
                                //Check if silo has been checked before
151
                                if(!isset($lastAmount) || $gooDifference < 0){
152
                                    setPermCache("couplingArray{$couplingID}Amount", $gooAmount);
153
                                    continue;
154
                                }
155
                                //Check for a multiple of 50 in the difference
156
                                if ($gooDifference % 50 != 0) {
157
                                    $gooType = apiTypeName($coupling->attributes()->typeID);
158
                                    $systemName = apiCharacterName($structures->attributes()->locationID);
159
                                    $msg = "{$siphonCorp["prefix"]}";
160
                                    $msg .= "**POSSIBLE SIPHON**\n";
161
                                    $msg .= "**System: **{$systemName} has a possible siphon stealing {$gooType} from a coupling array.\n";
162
                                    // Queue the message
163
                                    priorityQueueMessage($msg, $siphonCorp["channelID"], $this->guild);
164
                                    $this->logger->addInfo("Siphons: {$msg}");
165
                                    setPermCache("couplingArray{$couplingID}Amount", $gooAmount);
166
                                } else {
167
                                    setPermCache("couplingArray{$couplingID}Amount", $gooAmount);
168
                                }
169
                            }
170
                        }
171
                    }
172
                }
173
            }
174
            $cached = $xml->cachedUntil[0];
175
            $baseUnix = strtotime($cached);