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

Dispatcher::handle()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 22
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 22
rs 9.2
cc 3
eloc 6
nc 4
nop 0
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