Completed
Push — rework ( 30a2d6...381fae )
by Markus
02:34
created

BrowserDeviceListHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
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 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->output();
28
    }
29
}
30