PackageCommand::getCommands()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 20
cp 0
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Buttress\Concrete\Console\Command;
4
5
use Buttress\Concrete\Console\Command\Manager\CommandManager;
6
use Buttress\Concrete\Locator\Site;
7
use Buttress\Concrete\Route\RouteCollector;
8
9
class PackageCommand implements Command
10
{
11
12
    public function getCommands(Site $site)
13
    {
14
        // Install definition
15
        $install = new CommandManager('package:install');
16
        $install->add('handle', [
17
            'handle' => [
18
                'required' => true,
19
                'castTo' => 'string',
20
                'description' => 'The package handle to install'
21
            ]
22
        ]);
23
24
        // Uninstall definition
25
        $uninstall = new CommandManager('package:uninstall');
26
        $uninstall->add('handle', [
27
            'handle' => [
28
                'required' => true,
29
                'castTo' => 'string',
30
                'description' => 'The package handle to uninstall'
31
            ]
32
        ]);
33
34
        return [$install, $uninstall];
35
    }
36
37
    public function registerRoutes(RouteCollector $collector, Site $site = null)
38
    {
39
        $collector->addGroup('package', function (RouteCollector $collector) {
40
            // install
41
            $collector->addRoute(
42
                'install',
43
                'Buttress\Concrete\Console\Command\Package\InstallController::install'
44
            );
45
46
            // uninstall
47
            $collector->addRoute(
48
                'uninstall',
49
                'Buttress\Concrete\Console\Command\Package\InstallController::uninstall'
50
            );
51
52
            // list
53
            $collector->addRoute(
54
                'list',
55
                'Buttress\Concrete\Console\Command\Package\InstallController::listPackages'
56
            );
57
        });
58
    }
59
}
60