Code Duplication    Length = 3-6 lines in 3 locations

code/control/ApprovalsDispatcher.php 3 locations

@@ 186-191 (lines=6) @@
183
		// check for specific permission depending on the current state of the deployment:
184
		// submitted => approved requires approval permissions
185
		// new => approved requires bypass permissions.
186
		if (
187
			$deployment->State === DNDeployment::STATE_SUBMITTED
188
			&& !$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())
189
		) {
190
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
191
		}
192
		if (
193
			$deployment->State === DNDeployment::STATE_NEW
194
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
@@ 192-197 (lines=6) @@
189
		) {
190
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
191
		}
192
		if (
193
			$deployment->State === DNDeployment::STATE_NEW
194
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
195
		) {
196
			return $this->getAPIResponse(['message' => 'You are not authorised to bypass approval of this deployment'], 403);
197
		}
198
199
		try {
200
			$deployment->getMachine()->apply(DNDeployment::TR_APPROVE);
@@ 228-230 (lines=3) @@
225
			return $errorResponse;
226
		}
227
		// reject permissions are the same as can approve
228
		if (!$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())) {
229
			return $this->getAPIResponse(['message' => 'You are not authorised to reject this deployment'], 403);
230
		}
231
232
		try {
233
			$deployment->getMachine()->apply(DNDeployment::TR_REJECT);