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

DisplayControllerCreate   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 23
loc 23
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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