Server   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chinstrap\Core\Console\Commands;
6
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
final class Server extends Command
13
{
14
    protected function configure(): void
15
    {
16
        $this->setName('server')
17
            ->addOption('port', 'p', InputOption::VALUE_OPTIONAL, 'Which port should the server run on?')
18
            ->setDescription('Runs the development server')
19
            ->setHelp('This command runs the development server');
20
    }
21
22
    protected function execute(InputInterface $input, OutputInterface $output): int
23
    {
24
        if (!$port = $input->getOption('port')) {
25
            $port = 8000;
26
        }
27
        $output->writeln('Running PHP development server on port ' . $port . '...');
28
        passthru('php -S localhost:' . $port . ' -t ' . getcwd() . '/public public/router.php');
29
        return 1;
30
    }
31
}
32