Passed
Branch master (b0d099)
by Markus
03:49
created

BrowserDeviceListHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

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

1 Method

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