Completed
Push — rework ( b64e66...30a2d6 )
by Markus
02:47
created

BrowserAllPackagesListHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace SSpkS\Handler;
4
5
use \SSpkS\Output\HtmlOutput;
6
use \SSpkS\Package\PackageFinder;
7
8
class BrowserAllPackagesListHandler implements HandlerInterface
9
{
10
    private $config;
11
12
    public function __construct(\SSpkS\Config $config)
13
    {
14
        $this->config = $config;
15
    }
16
17
    public function handle()
18
    {
19
        // No architecture, but full list of packages requested --> show simple list
20
        $output = new HtmlOutput($this->config);
21
22
        $pkgs = new PackageFinder($this->config->paths['packages']);
23
        $packagesList = $pkgs->getAllPackageFiles();
24
25
        // Prepare data for template
26
        $packages = array();
27
        foreach ($packagesList as $spkFile) {
28
            $packages[] = array(
29
                'url'      => $this->config->baseUrl . $spkFile,
30
                'filename' => basename($spkFile),
31
            );
32
        }
33
        $output->setVariable('packagelist', $packages);
34
        $output->setTemplate('html_packagelist_all');
35
        $output->output();
36
    }
37
}
38