Completed
Push — master ( e903e9...7757ee )
by Michael
01:54
created

DisplayControllerCreate::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\Controllers;
10
11
use Joomla\Controller\AbstractController;
12
13
/**
14
 * Controller for displaying submitted statistics data.
15
 *
16
 * @method         \Joomla\StatsServer\WebApplication  getApplication()  Get the application object.
17
 * @property-read  \Joomla\StatsServer\WebApplication  $app              Application object
18
 */
19 View Code Duplication
class DisplayControllerCreate extends AbstractController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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