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

Handler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 33
ccs 0
cts 19
cp 0
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A handle() 0 12 3
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