Failed Conditions
Branch newinternal (104de7)
by Simon
09:33
created

ApiRequestRouter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getActionList() 0 4 1
B route() 0 27 6
1
<?php
2
3
namespace Waca\Router;
4
5
use Exception;
6
use Waca\API\Actions\CountAction;
7
use Waca\API\Actions\HelpAction;
8
use Waca\API\Actions\MonitorAction;
9
use Waca\API\Actions\StatsAction;
10
use Waca\API\Actions\StatusAction;
11
use Waca\API\Actions\UnknownAction;
12
use Waca\Tasks\IRoutedTask;
13
use Waca\WebRequest;
14
15
class ApiRequestRouter implements IRequestRouter
16
{
17
	/**
18
	 * @return string[]
19
	 */
20
	public static function getActionList()
21
	{
22
		return array("count", "status", "stats", "help", "monitor");
23
	}
24
25
	/**
26
	 * @return IRoutedTask
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use CountAction|StatusAction...elpAction|MonitorAction.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
27
	 * @throws Exception
28
	 */
29
	public function route()
30
	{
31
		$requestAction = WebRequest::getString('action');
32
33
		switch ($requestAction) {
34
			case "count":
35
				$result = new CountAction();
36
				break;
37
			case "status":
38
				$result = new StatusAction();
39
				break;
40
			case "stats":
41
				$result = new StatsAction();
42
				break;
43
			case "help":
44
				$result = new HelpAction();
45
				break;
46
			case "monitor":
47
				$result = new MonitorAction();
48
				break;
49
			default:
50
				$result = new UnknownAction();
51
				break;
52
		}
53
54
		return $result;
55
	}
56
}