Completed
Push — master ( 416cb1...222de5 )
by Anton
03:44
created

Dispatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 22 3
1
<?php
2
3
namespace {
4
5
	use Utils\Map;
6
7
	class Dispatcher extends System {
8
9
		# Dispatcher handle method
10
11
		public function handle() {
12
13
			# Check installation
14
15
			if (!$this->installed) Request::redirect(INSTALL_PATH . '/install.php');
16
17
			# Connect to database
18
19
			DB::connect(...array_values($this->database));
0 ignored issues
show
Bug introduced by
The call to connect() misses some required arguments starting with $user.
Loading history...
Documentation introduced by
array_values($this->database) is of type array<integer,?>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
20
21
			# Get handler by requested url
22
23
			$handler = (new Map())->handler($url = new Url(Request::get('url')));
24
25
			# Determine handler class
26
27
			$class = ((false !== $handler) ? ('Handlers\\' . $handler) : 'Handlers\Site\Page');
28
29
			# ------------------------
30
31
			new $class($url);
32
		}
33
	}
34
}
35