Handler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 17
c 3
b 0
f 0
dl 0
loc 29
ccs 0
cts 11
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 3
A __construct() 0 12 1
1
<?php
2
3
// Starting point, handle incoming request and hand over to more specific handler
4
5
namespace SSpkS;
6
7
class Handler
8
{
9
    private $config;
10
    private $handlerList;
11
12
    public function __construct(\SSpkS\Config $config)
13
    {
14
        $this->config = $config;
15
16
        // ordered by priority (top to bottom)
17
        $this->handlerList = array(
18
            'SynologyHandler',
19
            'BrowserRedirectHandler',
20
            'BrowserPackageListHandler',
21
            'BrowserAllPackagesListHandler',
22
            'BrowserDeviceListHandler',
23
            'NotFoundHandler'
24
        );
25
    }
26
27
    public function handle()
28
    {
29
        foreach ($this->handlerList as $possibleHandler) {
30
            // Add namespace to class name
31
            $possibleHandler = '\\SSpkS\\Handler\\' . $possibleHandler;
32
            $handler = new $possibleHandler($this->config);
33
            if ($handler->canHandle()) {
34
                $handler->handle();
35
                break;
36
            }
37
        }
38
    }
39
}
40