Code Duplication    Length = 13-13 lines in 4 locations

code/tasks/CleanupOrphanedRecordsTask.php 4 locations

@@ 28-40 (lines=13) @@
25
			}
26
		}
27
28
		foreach (DNDataTransfer::get() as $transfer) {
29
			$environment = $transfer->Environment();
30
			if (!$environment || !$environment->exists()) {
31
				$log(sprintf(
32
					'Data transfer (ID %s, Created: %s) is linked to a non-existent environment. Deleting',
33
					$transfer->ID,
34
					$transfer->Created
35
				));
36
				$transfer->delete();
37
				$transfer->destroy();
38
				$count++;
39
			}
40
		}
41
42
		foreach (DNDataArchive::get() as $archive) {
43
			$environment = $archive->Environment();
@@ 42-54 (lines=13) @@
39
			}
40
		}
41
42
		foreach (DNDataArchive::get() as $archive) {
43
			$environment = $archive->Environment();
44
			if (!$environment || !$environment->exists()) {
45
				$log(sprintf(
46
					'Archive (ID %s, Created: %s) is linked to a non-existent environment. Deleting',
47
					$archive->ID,
48
					$archive->Created
49
				));
50
				$archive->delete();
51
				$archive->destroy();
52
				$count++;
53
			}
54
		}
55
56
		foreach (DNGitFetch::get() as $fetch) {
57
			$project = $fetch->Project();
@@ 56-68 (lines=13) @@
53
			}
54
		}
55
56
		foreach (DNGitFetch::get() as $fetch) {
57
			$project = $fetch->Project();
58
			if (!$project || !$project->exists()) {
59
				$log(sprintf(
60
					'Git fetch (ID %s, Created: %s) is linked to a non-existent project. Deleting',
61
					$fetch->ID,
62
					$fetch->Created
63
				));
64
				$fetch->delete();
65
				$fetch->destroy();
66
				$count++;
67
			}
68
		}
69
70
		foreach (DNPing::get() as $ping) {
71
			$environment = $ping->Environment();
@@ 70-82 (lines=13) @@
67
			}
68
		}
69
70
		foreach (DNPing::get() as $ping) {
71
			$environment = $ping->Environment();
72
			if (!$environment || !$environment->exists()) {
73
				$log(sprintf(
74
					'Ping (ID %s, Created: %s) is linked to a non-existent environment. Deleting',
75
					$ping->ID,
76
					$ping->Created
77
				));
78
				$ping->delete();
79
				$ping->destroy();
80
				$count++;
81
			}
82
		}
83
84
		$log(sprintf('Finished. Processed %s records', $count));
85
	}