Completed
Push — master ( ed845b...38c1c8 )
by Luke
04:37
created

InstallCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
ccs 0
cts 3
cp 0
rs 9.6666
cc 1
eloc 8
nc 1
nop 6
crap 2
1
<?php
2
3
/**
4
 * Moodle component manager.
5
 *
6
 * @author Luke Carrier <[email protected]>
7
 * @copyright 2016 Luke Carrier
8
 * @license GPL-3.0+
9
 */
10
11
namespace ComponentManager\Command;
12
13
use ComponentManager\Moodle;
14
use ComponentManager\PackageFormat\PackageFormatFactory;
15
use ComponentManager\PackageRepository\PackageRepositoryFactory;
16
use ComponentManager\PackageSource\PackageSourceFactory;
17
use ComponentManager\Platform\Platform;
18
use ComponentManager\Task\InstallTask;
19
use Psr\Log\LoggerInterface;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Output\OutputInterface;
22
use Symfony\Component\Filesystem\Filesystem;
23
24
/**
25
 * Install command.
26
 *
27
 * Installs a component into the Moodle installation in the present working
28
 * directory.
29
 */
30
class InstallCommand extends ProjectAwareCommand {
31
    /**
32
     * Help text.
33
     *
34
     * @var string
35
     */
36
    const HELP = <<<HELP
37
Installs, into the Moodle installation in the present working directory, all of the components listed in its componentmgr.json file.
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 132 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
38
HELP;
39
40
    /**
41
     * Initialiser.
42
     *
43
     * @param \ComponentManager\PackageRepository\PackageRepositoryFactory $packageRepositoryFactory
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 100 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
44
     * @param \ComponentManager\PackageSource\PackageSourceFactory $packageSourceFactory
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 88 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
45
     * @param \ComponentManager\PackageFormat\PackageFormatFactory $packageFormatFactory
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 88 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
46
     * @param \ComponentManager\Platform\Platform                  $platform
47
     * @param \Symfony\Component\Filesystem\Filesystem             $filesystem
48
     * @param \Psr\Log\LoggerInterface                             $logger
49
     */
50
    public function __construct(PackageRepositoryFactory $packageRepositoryFactory,
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 83 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
51
                                PackageSourceFactory $packageSourceFactory,
52
                                PackageFormatFactory $packageFormatFactory,
53
                                Platform $platform, Filesystem $filesystem,
54
                                LoggerInterface $logger) {
55
        parent::__construct(
56
                $packageRepositoryFactory, $packageSourceFactory,
57
                $packageFormatFactory, $platform, $filesystem, $logger);
58
    }
59
60
    /**
61
     * @override \Symfony\Component\Console\Command\Command
62
     */
63
    protected function configure() {
64
        $this
65
            ->setName('install')
66
            ->setDescription('Installs all packages from componentmgr.json')
67
            ->setHelp(static::HELP);
68
    }
69
70
    /**
71
     * @override \Symfony\Component\Console\Command\Command
72
     */
73
    protected function execute(InputInterface $input, OutputInterface $output) {
74
        $project = $this->getProject();
75
        $moodle  = new Moodle(
76
                $this->platform->getWorkingDirectory(), $this->platform);
77
78
        $task = new InstallTask(
79
                $project, $this->platform, $this->filesystem, $moodle);
80
        $task->execute($this->logger);
81
    }
82
}
83