Passed
Branch master (3fb2a1)
by Andrés
02:45
created

DumpAutoloadTask   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A execute() 0 9 1
A getComposerOptions() 0 3 1
A getDescription() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Magallanes package.
5
 *
6
 * (c) Andrés Montañez <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mage\Task\BuiltIn\Composer;
13
14
use Symfony\Component\Process\Process;
15
16
/**
17
 * Composer Task - Generate Autoload
18
 *
19
 * @author Andrés Montañez <[email protected]>
20
 */
21
class DumpAutoloadTask extends AbstractComposerTask
22
{
23 48
    public function getName(): string
24
    {
25 48
        return 'composer/dump-autoload';
26
    }
27
28 29
    public function getDescription(): string
29
    {
30 29
        return '[Composer] Dump Autoload';
31
    }
32
33 28
    public function execute(): bool
34
    {
35 28
        $options = $this->getOptions();
36 28
        $cmd = sprintf('%s dump-autoload %s', $options['path'], $options['flags']);
37
38
        /** @var Process $process */
39 28
        $process = $this->runtime->runCommand(trim($cmd));
40
41 28
        return $process->isSuccessful();
42
    }
43
44 28
    protected function getComposerOptions(): array
45
    {
46 28
        return ['flags' => '--optimize'];
47
    }
48
}
49