Code Duplication    Length = 3-6 lines in 3 locations

code/control/ApprovalsDispatcher.php 3 locations

@@ 192-197 (lines=6) @@
189
		// check for specific permission depending on the current state of the deployment:
190
		// submitted => approved requires approval permissions
191
		// new => approved requires bypass permissions.
192
		if (
193
			$deployment->State === DNDeployment::STATE_SUBMITTED
194
			&& !$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())
195
		) {
196
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
197
		}
198
		if (
199
			$deployment->State === DNDeployment::STATE_NEW
200
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
@@ 198-203 (lines=6) @@
195
		) {
196
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
197
		}
198
		if (
199
			$deployment->State === DNDeployment::STATE_NEW
200
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
201
		) {
202
			return $this->getAPIResponse(['message' => 'You are not authorised to bypass approval of this deployment'], 403);
203
		}
204
205
		// if the current user is not the person who was selected for approval on submit, but they got
206
		// here because they still have permission, then change the approver to the current user
@@ 241-243 (lines=3) @@
238
			return $errorResponse;
239
		}
240
		// reject permissions are the same as can approve
241
		if (!$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())) {
242
			return $this->getAPIResponse(['message' => 'You are not authorised to reject this deployment'], 403);
243
		}
244
245
		// if the current user is not the person who was selected for approval on submit, but they got
246
		// here because they still have permission, then change the approver to the current user