Code Duplication    Length = 3-6 lines in 3 locations

code/control/ApprovalsDispatcher.php 3 locations

@@ 205-210 (lines=6) @@
202
		// check for specific permission depending on the current state of the deployment:
203
		// submitted => approved requires approval permissions
204
		// new => approved requires bypass permissions.
205
		if (
206
			$deployment->State === DNDeployment::STATE_SUBMITTED
207
			&& !$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())
208
		) {
209
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
210
		}
211
		if (
212
			$deployment->State === DNDeployment::STATE_NEW
213
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
@@ 211-216 (lines=6) @@
208
		) {
209
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
210
		}
211
		if (
212
			$deployment->State === DNDeployment::STATE_NEW
213
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
214
		) {
215
			return $this->getAPIResponse(['message' => 'You are not authorised to bypass approval of this deployment'], 403);
216
		}
217
218
		if ($deployment->State === DNDeployment::STATE_NEW) {
219
			// Bypassing approval: Ensure that approver is not set. This may happen when someone has requested approval,
@@ 271-273 (lines=3) @@
268
			return $errorResponse;
269
		}
270
		// reject permissions are the same as can approve
271
		if (!$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())) {
272
			return $this->getAPIResponse(['message' => 'You are not authorised to reject this deployment'], 403);
273
		}
274
275
		// if the current user is not the person who was selected for approval on submit, but they got
276
		// here because they still have permission, then change the approver to the current user