BrowserPackageListHandler::canHandle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 1
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 12
rs 10
1
<?php
2
3
namespace SSpkS\Handler;
4
5
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...
6
use \SSpkS\Output\UrlFixer;
0 ignored issues
show
Bug introduced by
The type \SSpkS\Output\UrlFixer 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
use \SSpkS\Package\PackageFilter;
0 ignored issues
show
Bug introduced by
The type \SSpkS\Package\PackageFilter 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...
8
use \SSpkS\Package\PackageFinder;
0 ignored issues
show
Bug introduced by
The type \SSpkS\Package\PackageFinder 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...
9
10
class BrowserPackageListHandler extends AbstractHandler
11
{
12
    public function canHandle()
13
    {
14
        return ($_SERVER['REQUEST_METHOD'] == 'GET' && array_key_exists('arch', $_GET) && !empty(trim($_GET['arch'])));
15
    }
16
17
    public function handle()
18
    {
19
        // Architecture is set --> show packages for that arch
20
        $arch = trim($_GET['arch']);
21
22
        $output = new HtmlOutput($this->config);
23
        $output->setVariable('arch', $arch);
24
25
        $pkgs = new PackageFinder($this->config);
26
        $pkgf = new PackageFilter($this->config, $pkgs->getAllPackages());
27
        $pkgf->setArchitectureFilter($arch);
28
        $pkgf->setFirmwareVersionFilter(false);
29
        $pkgf->setOldVersionFilter(true);
30
        $filteredPkgList = $pkgf->getFilteredPackageList();
31
32
        $uf = new UrlFixer($this->config->baseUrl);
33
        $uf->fixPackageList($filteredPkgList);
34
35
        $packages = array();
36
        foreach ($filteredPkgList as $pkg) {
37
            $pkgMeta = $pkg->getMetadata();
38
            $packages[$pkgMeta['displayname']] = $pkgMeta;
39
        }
40
41
        ksort($packages, SORT_NATURAL | SORT_FLAG_CASE);
42
43
        $output->setVariable('packagelist', array_values($packages));
44
        $output->setTemplate('html_packagelist');
45
        $output->output();
46
    }
47
}
48