Completed
Push — rework ( d09de3...810325 )
by Markus
03:02
created

Handler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
// Starting point, handle incoming request and hand over to more specific handler
4
5
namespace SSpkS;
6
7
use \SSpkS\Handler\BrowserHandler;
8
use \SSpkS\Handler\NotFoundHandler;
9
use \SSpkS\Handler\SynologyHandler;
10
11
class Handler
12
{
13
    private $config;
14
15
    public function __construct(\SSpkS\Config $config)
16
    {
17
        $this->config = $config;
18
    }
19
20
    public function handle()
21
    {
22
        // TODO: Probably walk through all known handlers and query them whether they're
23
        //       responsible/capable for answering the request or not. Take the best match.
24
25
        if (isset($_REQUEST['unique']) && substr($_REQUEST['unique'], 0, 8) == 'synology') {
26
            $handler = new SynologyHandler($this->config);
27
        } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
28
            $handler = new BrowserHandler($this->config);
29
        } else {
30
            $handler = new NotFoundHandler($this->config);
31
        }
32
        $handler->handle();
33
    }
34
}
35