Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
created

SubmitControllerGet::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
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 processing 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
class SubmitControllerGet extends AbstractController
20
{
21
	/**
22
	 * Execute the controller.
23
	 *
24
	 * @return  boolean
25
	 */
26 1
	public function execute()
27
	{
28
		$response = [
29 1
			'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 1
		$this->getApplication()->setHeader('HTTP/1.1 405 Method Not Allowed', 405, true);
35 1
		$this->getApplication()->setHeader('Allow', 'POST');
36
37 1
		$this->getApplication()->setBody(json_encode($response));
38
39 1
		return true;
40
	}
41
}
42