Code Duplication    Length = 13-16 lines in 5 locations

includes/Pages/PageEmailManagement.php 1 location

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

includes/Pages/RequestAction/PageCloseRequest.php 1 location

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

includes/Pages/RequestAction/PageCustomClose.php 1 location

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

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/PageViewRequest.php 1 location

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