Completed
Push — master ( 59cf45...89a6d0 )
by Markus
02:34
created

BrowserAllPackagesListHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
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 29
ccs 0
cts 17
cp 0
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 4 2
A handle() 0 21 2
1
<?php
2
3
namespace SSpkS\Handler;
4
5
use \SSpkS\Output\HtmlOutput;
6
use \SSpkS\Package\PackageFinder;
7
8
class BrowserAllPackagesListHandler extends AbstractHandler
9
{
10
    public function canHandle()
11
    {
12
        return ($_SERVER['REQUEST_METHOD'] == '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->paths['packages']);
21
        $packagesList = $pkgs->getAllPackageFiles();
22
23
        // Prepare data for template
24
        $packages = array();
25
        foreach ($packagesList as $spkFile) {
26
            $packages[] = array(
27
                'url'      => $this->config->baseUrl . $spkFile,
28
                'filename' => basename($spkFile),
29
            );
30
        }
31
        $output->setVariable('packagelist', $packages);
32
        $output->setVariable('fullList', true);
33
        $output->setTemplate('html_packagelist_all');
34
        $output->output();
35
    }
36
}
37