Code Duplication    Length = 13-16 lines in 4 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/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

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