Completed
Push — master ( 59cf45...89a6d0 )
by Markus
02:34
created

Handler::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 0
loc 12
ccs 0
cts 9
cp 0
crap 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
// Starting point, handle incoming request and hand over to more specific handler
4
5
namespace SSpkS;
6
7
class Handler
0 ignored issues
show
Coding Style introduced by
The property $handler_list is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
8
{
9
    private $config;
10
    private $handler_list;
11
12
    public function __construct(\SSpkS\Config $config)
13
    {
14
        $this->config = $config;
15
16
        // ordered by priority (top to bottom)
17
        $this->handler_list = array(
18
            'SynologyHandler',
19
            'BrowserRedirectHandler',
20
            'BrowserPackageListHandler',
21
            'BrowserAllPackagesListHandler',
22
            'BrowserDeviceListHandler',
23
            'NotFoundHandler'
24
        );
25
    }
26
27
    public function handle()
28
    {
29
        foreach ($this->handler_list as $possible_handler) {
30
            // Add namespace to class name
31
            $possible_handler = '\\SSpkS\\Handler\\' . $possible_handler;
32
            $handler = new $possible_handler($this->config);
33
            if ($handler->canHandle()) {
34
                $handler->handle();
35
                break;
36
            }
37
        }
38
    }
39
}
40