Code Duplication    Length = 4-12 lines in 3 locations

Sources/Subs-Package.php 3 locations

@@ 2174-2177 (lines=4) @@
2171
							// Reversing a before/after modification becomes a replacement.
2172
							$actual_operation['searches'][$i]['position'] = 'replace';
2173
2174
							if ($search['position'] === 'before')
2175
								$actual_operation['searches'][$i]['search'] .= $search['add'];
2176
							elseif ($search['position'] === 'after')
2177
								$actual_operation['searches'][$i]['search'] = $search['add'] . $search['search'];
2178
						}
2179
2180
						// ...and the search subject is now the replacement.
@@ 2228-2232 (lines=5) @@
2225
					}
2226
2227
					// After, after what?
2228
					elseif ($search['position'] === 'after')
2229
					{
2230
						$actual_operation['searches'][$i]['preg_search'] = '(' . $actual_operation['searches'][$i]['preg_search'] . ')';
2231
						$actual_operation['searches'][$i]['preg_replace'] .= '$1';
2232
					}
2233
2234
					// Position the replacement at the end of the file (or just before the closing PHP tags).
2235
					elseif ($search['position'] === 'end')
@@ 2235-2246 (lines=12) @@
2232
					}
2233
2234
					// Position the replacement at the end of the file (or just before the closing PHP tags).
2235
					elseif ($search['position'] === 'end')
2236
					{
2237
						if ($undo)
2238
						{
2239
							$actual_operation['searches'][$i]['preg_replace'] = '';
2240
						}
2241
						else
2242
						{
2243
							$actual_operation['searches'][$i]['preg_search'] = '(\\n\\?\\>)?$';
2244
							$actual_operation['searches'][$i]['preg_replace'] .= '$1';
2245
						}
2246
					}
2247
2248
					// Testing 1, 2, 3...
2249
					$failed = preg_match('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $working_data) === 0;