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

BrowserDeviceListHandler::handle()   A

Complexity

Conditions 3
Paths 8

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 14
nc 8
nop 0
dl 0
loc 19
ccs 0
cts 14
cp 0
crap 12
rs 9.4285
c 1
b 0
f 0
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