Completed
Push — master ( 390e4e...b0ec12 )
by Taosikai
12:57
created

SpikeCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 8 1
A getNativeDefinition() 0 4 1
A createDefinition() 0 11 1
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Server\Command;
7
8
use Symfony\Component\Console\Helper\DescriptorHelper;
9
use Symfony\Component\Console\Input\InputDefinition;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class SpikeCommand extends Command
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected function configure()
20
    {
21
        $this->ignoreValidationErrors();
22
        $this->setName('spiked')
23
            ->setDefinition($this->createDefinition())
24
            ->setDescription('Spike is a reverse proxy that help to expose your local server to the internet.');
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function execute(InputInterface $input, OutputInterface $output)
31
    {
32
        $helper = new DescriptorHelper();
33
        $helper->describe($output, $this, array(
34
            'format' => $input->getOption('format'),
35
            'raw_text' => $input->getOption('raw'),
36
        ));
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getNativeDefinition()
43
    {
44
        return $this->createDefinition();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    private function createDefinition()
51
    {
52
        return new InputDefinition(array(
53
            new InputOption('config', null, InputOption::VALUE_OPTIONAL,
54
                'The configuration file, support json,ini,xml and yaml format'),
55
            new InputOption('address', null, InputOption::VALUE_OPTIONAL,
56
                'The server address'),
57
            new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
58
            new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
59
        ));
60
    }
61
}