Passed
Push — master ( 4afc78...9d1371 )
by Evgenii
01:53
created

BuildSubcommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Helick\LocalServer\Subcommands;
4
5
use Symfony\Component\Console\Application;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Process\Process;
9
10
final class BuildSubcommand
11
{
12
    /**
13
     * The application instance.
14
     *
15
     * @var Application
16
     */
17
    private $application;
18
19
    /**
20
     * Create a subcommand instance.
21
     *
22
     * @param Application $application
23
     *
24
     * @return void
25
     */
26
    public function __construct(Application $application)
27
    {
28
        $this->application = $application;
29
    }
30
31
    /**
32
     * Invoke the subcommand.
33
     *
34
     * @param InputInterface  $input
35
     * @param OutputInterface $output
36
     *
37
     * @return void
38
     */
39
    public function __invoke(InputInterface $input, OutputInterface $output): void
40
    {
41
        $output->writeln('Building...');
42
43
        $compose = new Process('docker-compose build', 'vendor/helick/local-server/docker', [
0 ignored issues
show
Bug introduced by
'docker-compose build' of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        $compose = new Process(/** @scrutinizer ignore-type */ 'docker-compose build', 'vendor/helick/local-server/docker', [
Loading history...
44
            'COMPOSE_PROJECT_NAME' => basename(getcwd()),
45
            'VOLUME'               => getcwd(),
46
        ]);
47
        $compose->run(function ($_, $buffer) {
48
            echo $buffer;
49
        });
50
51
        $output->writeln('Built.');
52
    }
53
}
54