BrowserDeviceListHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 15
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 3 1
A handle() 0 19 3
1
<?php
2
3
namespace SSpkS\Handler;
4
5
use \SSpkS\Device\DeviceList;
0 ignored issues
show
Bug introduced by
The type \SSpkS\Device\DeviceList was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use \SSpkS\Output\HtmlOutput;
0 ignored issues
show
Bug introduced by
The type \SSpkS\Output\HtmlOutput was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class BrowserDeviceListHandler extends AbstractHandler
9
{
10
    public function canHandle()
11
    {
12
        return ($_SERVER['REQUEST_METHOD'] == 'GET');
13
    }
14
15
    public function handle()
16
    {
17
        // Nothing requested --> show models overview
18
        $output = new HtmlOutput($this->config);
19
        try {
20
            $deviceList = new DeviceList($this->config);
21
            $models = $deviceList->getDevices();
22
            if (count($models) == 0) {
23
                $output->setTemplate('html_modellist_none');
24
            } else {
25
                $output->setVariable('modellist', $models);
26
                $output->setTemplate('html_modellist');
27
            }
28
        } catch (\Exception $e) {
29
            $output->setVariable('errorMessage', $e->getMessage());
30
            $output->setTemplate('html_modellist_error');
31
        }
32
        $output->setVariable('is_devicelist', true);
33
        $output->output();
34
    }
35
}
36