Passed
Push — master ( f8a196...66e67e )
by Evgenii
01:52
created

StartSubcommand::__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\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
final class StartSubcommand extends Subcommand
9
{
10
    /**
11
     * The process' command string.
12
     *
13
     * @var string
14
     */
15
    const COMMAND = 'docker-compose up -d';
16
17
    /**
18
     * Invoke the subcommand.
19
     *
20
     * @param InputInterface  $input
21
     * @param OutputInterface $output
22
     *
23
     * @return void
24
     */
25
    public function __invoke(InputInterface $input, OutputInterface $output): void
26
    {
27
        $output->writeln('Starting...');
28
29
        $process = $this->runProcess(static::COMMAND);
30
31
        if (!$process->isSuccessful()) {
32
            return;
33
        }
34
35
        $output->writeln('Started.');
36
        $output->writeln('');
37
        $output->writeln(sprintf(
38
            'To access site please visit: http://%s.localtest.me/',
39
            basename(getcwd())
40
        ));
41
        $output->writeln(sprintf(
42
            'To access phpmyadmin please visit: http://phpmyadmin.%s.localtest.me/',
43
            basename(getcwd())
44
        ));
45
        $output->writeln(sprintf(
46
            'To access elasticsearch please visit: http://elasticsearch.%s.localtest.me/',
47
            basename(getcwd())
48
        ));
49
    }
50
}
51