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
		// if the current user is not the person who was selected for approval on submit, but they got
200
		// here because they still have permission, then change the approver to the current user
@@ 235-237 (lines=3) @@
232
			return $errorResponse;
233
		}
234
		// reject permissions are the same as can approve
235
		if (!$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())) {
236
			return $this->getAPIResponse(['message' => 'You are not authorised to reject this deployment'], 403);
237
		}
238
239
		// if the current user is not the person who was selected for approval on submit, but they got
240
		// here because they still have permission, then change the approver to the current user