Code Duplication    Length = 23-23 lines in 2 locations

src/Controllers/DisplayControllerCreate.php 1 location

@@ 19-41 (lines=23) @@
16
 * @method         \Joomla\StatsServer\WebApplication  getApplication()  Get the application object.
17
 * @property-read  \Joomla\StatsServer\WebApplication  $app              Application object
18
 */
19
class DisplayControllerCreate extends AbstractController
20
{
21
	/**
22
	 * Execute the controller.
23
	 *
24
	 * @return  boolean
25
	 */
26
	public function execute()
27
	{
28
		$response = [
29
			'error'   => true,
30
			'message' => 'This route only accepts GET requests.'
31
		];
32
33
		// Set the response headers to indicate the method is not allowed
34
		$this->getApplication()->setHeader('HTTP/1.1 405 Method Not Allowed', 405, true);
35
		$this->getApplication()->setHeader('Allow', 'GET');
36
37
		$this->getApplication()->setBody(json_encode($response));
38
39
		return true;
40
	}
41
}
42

src/Controllers/SubmitControllerGet.php 1 location

@@ 19-41 (lines=23) @@
16
 * @method         \Joomla\StatsServer\WebApplication  getApplication()  Get the application object.
17
 * @property-read  \Joomla\StatsServer\WebApplication  $app              Application object
18
 */
19
class SubmitControllerGet extends AbstractController
20
{
21
	/**
22
	 * Execute the controller.
23
	 *
24
	 * @return  boolean
25
	 */
26
	public function execute()
27
	{
28
		$response = [
29
			'error'   => true,
30
			'message' => 'This route only accepts POST requests.'
31
		];
32
33
		// Set the response headers to indicate the method is not allowed
34
		$this->getApplication()->setHeader('HTTP/1.1 405 Method Not Allowed', 405, true);
35
		$this->getApplication()->setHeader('Allow', 'POST');
36
37
		$this->getApplication()->setBody(json_encode($response));
38
39
		return true;
40
	}
41
}
42