Completed
Push — rework ( b64e66...30a2d6 )
by Markus
02:47
created

BrowserDeviceListHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 19 3
1
<?php
2
3
namespace SSpkS\Handler;
4
5
use \SSpkS\Device\DeviceList;
6
use \SSpkS\Output\HtmlOutput;
7
8
class BrowserDeviceListHandler implements HandlerInterface
9
{
10
    private $config;
11
12
    public function __construct(\SSpkS\Config $config)
13
    {
14
        $this->config = $config;
15
    }
16
17
    public function handle()
18
    {
19
        // Nothing requested --> show models overview
20
        $output = new HtmlOutput($this->config);
21
        try {
22
            $deviceList = new DeviceList($this->config->paths['models']);
23
            $models = $deviceList->getDevices();
24
            if (count($models) == 0) {
25
                $output->setTemplate('html_modellist_none');
26
            } else {
27
                $output->setVariable('modellist', $models);
28
                $output->setTemplate('html_modellist');
29
            }
30
        } catch (\Exception $e) {
31
            $output->setVariable('errorMessage', $e->getMessage());
32
            $output->setTemplate('html_modellist_error');
33
        }
34
        $output->output();
35
    }
36
}
37