InstallDependenciesStep::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zalas\Symfify\Composer\SymfifyStep;
6
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Zalas\Symfify\Composer\SymfifyStep;
9
10
class InstallDependenciesStep implements SymfifyStep
11
{
12
    /**
13
     * @var array
14
     */
15
    private $dependencies = [
16
        'symfony/framework-bundle',
17
    ];
18
19
    /**
20
     * @var OutputInterface
21
     */
22
    private $output;
23
24 4
    public function __construct(OutputInterface $output, array $dependencies = [])
25
    {
26 4
        $this->output = $output;
27 4
        $this->dependencies = $dependencies ?: $this->dependencies;
28
    }
29
30 2
    public function __invoke()
31
    {
32 2
        $this->output->writeln(\sprintf('Installing <comment>%s</comment>', \implode('</comment>, <comment>', $this->dependencies)));
33
34 2
        \system(\sprintf('composer require -q %s', \implode(' ', \array_map('escapeshellarg', $this->dependencies))));
35
    }
36
}
37