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

BrowserAllPackagesListHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 30
ccs 0
cts 17
cp 0
rs 10
c 1
b 0
f 0
wmc 3
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 20 2
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