BrowserAllPackagesListHandler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 3 3
A handle() 0 21 2
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\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...
7
8
class BrowserAllPackagesListHandler extends AbstractHandler
9
{
10
    public function canHandle()
11
    {
12
        return ($_SERVER['REQUEST_METHOD'] == 'GET' && array_key_exists('fulllist', $_GET) && !empty(trim($_GET['fulllist'])));
13
    }
14
15
    public function handle()
16
    {
17
        // No architecture, but full list of packages requested --> show simple list
18
        $output = new HtmlOutput($this->config);
19
20
        $pkgs = new PackageFinder($this->config);
21
        $packagesList = $pkgs->getAllPackageFiles();
22
23
        // Prepare data for template
24
        $packages = array();
25
        foreach ($packagesList as $spkFile) {
26
            $packages[basename($spkFile)] = array(
27
                'url'      => $this->config->baseUrl . $spkFile,
28
                'filename' => basename($spkFile),
29
            );
30
        }
31
        ksort($packages, SORT_NATURAL | SORT_FLAG_CASE);
32
        $output->setVariable('packagelist', array_values($packages));
33
        $output->setVariable('fullList', true);
34
        $output->setTemplate('html_packagelist_all');
35
        $output->output();
36
    }
37
}
38