Code Duplication    Length = 3-6 lines in 3 locations

code/control/ApprovalsDispatcher.php 3 locations

@@ 176-181 (lines=6) @@
173
		// check for specific permission depending on the current state of the deployment:
174
		// submitted => approved requires approval permissions
175
		// new => approved requires bypass permissions.
176
		if (
177
			$deployment->State === DNDeployment::STATE_SUBMITTED
178
			&& !$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())
179
		) {
180
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
181
		}
182
		if (
183
			$deployment->State === DNDeployment::STATE_NEW
184
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
@@ 182-187 (lines=6) @@
179
		) {
180
			return $this->getAPIResponse(['message' => 'You are not authorised to approve this deployment'], 403);
181
		}
182
		if (
183
			$deployment->State === DNDeployment::STATE_NEW
184
			&& !$this->project->allowed(self::ALLOW_APPROVAL_BYPASS, Member::currentUser())
185
		) {
186
			return $this->getAPIResponse(['message' => 'You are not authorised to bypass approval of this deployment'], 403);
187
		}
188
189
		try {
190
			$deployment->getMachine()->apply(DNDeployment::TR_APPROVE);
@@ 218-220 (lines=3) @@
215
			return $errorResponse;
216
		}
217
		// reject permissions are the same as can approve
218
		if (!$this->project->allowed(self::ALLOW_APPROVAL, Member::currentUser())) {
219
			return $this->getAPIResponse(['message' => 'You are not authorised to reject this deployment'], 403);
220
		}
221
222
		try {
223
			$deployment->getMachine()->apply(DNDeployment::TR_REJECT);