Code Duplication    Length = 13-16 lines in 5 locations

includes/Pages/RequestAction/RequestActionBase.php 1 location

@@ 25-40 (lines=16) @@
22
	 * @return Request
23
	 * @throws ApplicationLogicException
24
	 */
25
	protected function getRequest(PdoDatabase $database)
26
	{
27
		$requestId = WebRequest::postInt('request');
28
		if ($requestId === null) {
29
			throw new ApplicationLogicException('Request ID not found');
30
		}
31
32
		/** @var Request $request */
33
		$request = Request::getById($requestId, $database);
34
35
		if ($request === false) {
36
			throw new ApplicationLogicException('Request not found');
37
		}
38
39
		return $request;
40
	}
41
42
	final protected function checkPosted()
43
	{

includes/Pages/PageEmailManagement.php 1 location

@@ 87-99 (lines=13) @@
84
	 * @return EmailTemplate
85
	 * @throws ApplicationLogicException
86
	 */
87
	protected function getTemplate(PdoDatabase $database)
88
	{
89
		$templateId = WebRequest::getInt('id');
90
		if ($templateId === null) {
91
			throw new ApplicationLogicException('Template not specified');
92
		}
93
		$template = EmailTemplate::getById($templateId, $database);
94
		if ($template === false || !is_a($template, EmailTemplate::class)) {
95
			throw new ApplicationLogicException('Template not found');
96
		}
97
98
		return $template;
99
	}
100
101
	protected function edit()
102
	{

includes/Pages/PageViewRequest.php 1 location

@@ 111-126 (lines=16) @@
108
	 * @return Request
109
	 * @throws ApplicationLogicException
110
	 */
111
	private function getRequest()
112
	{
113
		$requestId = WebRequest::getInt('id');
114
		if ($requestId === null) {
115
			throw new ApplicationLogicException("No request specified");
116
		}
117
118
		$database = $this->getDatabase();
119
120
		$request = Request::getById($requestId, $database);
121
		if ($request === false || !is_a($request, Request::class)) {
122
			throw new ApplicationLogicException('Could not load the requested request!');
123
		}
124
125
		return $request;
126
	}
127
128
	/**
129
	 * @param Request $request

includes/Pages/RequestAction/PageCloseRequest.php 1 location

@@ 98-112 (lines=15) @@
95
	 * @return EmailTemplate
96
	 * @throws ApplicationLogicException
97
	 */
98
	protected function getTemplate(PdoDatabase $database)
99
	{
100
		$templateId = WebRequest::postInt('template');
101
		if ($templateId === null) {
102
			throw new ApplicationLogicException('No template specified');
103
		}
104
105
		/** @var EmailTemplate $template */
106
		$template = EmailTemplate::getById($templateId, $database);
107
		if ($template === false || !$template->getActive()) {
108
			throw new ApplicationLogicException('Invalid or inactive template specified');
109
		}
110
111
		return $template;
112
	}
113
114
	/**
115
	 * @param Request       $request

includes/Pages/RequestAction/PageCustomClose.php 1 location

@@ 57-72 (lines=16) @@
54
	 * @return Request
55
	 * @throws ApplicationLogicException
56
	 */
57
	protected function getRequest(PdoDatabase $database)
58
	{
59
		$requestId = WebRequest::getInt('request');
60
		if ($requestId === null) {
61
			throw new ApplicationLogicException('Request ID not found');
62
		}
63
64
		/** @var Request $request */
65
		$request = Request::getById($requestId, $database);
66
67
		if ($request === false) {
68
			throw new ApplicationLogicException('Request not found');
69
		}
70
71
		return $request;
72
	}
73
74
	/**
75
	 * @param PdoDatabase $database