RunCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 19 1
1
<?php
2
3
namespace MS\Sentry\Monitor\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Style\SymfonyStyle;
10
use Symfony\Component\Process\ProcessBuilder;
11
12
class RunCommand extends Command
13
{
14
    /**
15
     * @inheritdoc
16
     */
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('run')
21
            ->setDescription('run sentry monitor server')
22
            ->addArgument('address', InputArgument::OPTIONAL, 'Address:port', 'localhost:8006')
23
        ;
24
    }
25
26
    /**
27
     * @param InputInterface  $input
28
     * @param OutputInterface $output
29
     *
30
     * @return void
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $io = new SymfonyStyle($input, $output);
35
        $io->title('Start and run sentry monitor');
36
37
        $address = $input->getArgument('address');
38
        $webPath = __DIR__ . '/../../web';
39
40
        $processBuilder = new ProcessBuilder([PHP_BINARY, '-S', $address, $webPath . '/index.php']);
41
        $processBuilder
42
            ->setWorkingDirectory($webPath . '/scripts')
43
            ->setTimeout(null);
44
45
        $io->success(sprintf('Server running on "%s"', $address));
46
        $io->comment('Quit the server with CONTROL-C.');
47
48
        $process = $processBuilder->getProcess();
49
        $process->run();
50
    }
51
}
52