Code Duplication    Length = 3-6 lines in 3 locations

code/control/ApprovalsDispatcher.php 3 locations

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