Completed
Push — master ( f35092...5c5205 )
by Gareth
12:24
created

TldrApplication   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCommandName() 0 5 1
A getDefaultCommands() 0 8 1
A getDefinition() 0 8 1
1
<?php
2
3
namespace GarethEllis\Tldr\Console;
4
5
use GarethEllis\Tldr\Console\Command\TldrCommand;
6
use Symfony\Component\Console\Application;
7
use Symfony\Component\Console\Input\InputInterface;
8
9
class TldrApplication extends Application
10
{
11
    /**
12
     * Gets the name of the command based on input.
13
     *
14
     * @param InputInterface $input The input interface
15
     *
16
     * @return string The command name
17
     */
18
    protected function getCommandName(InputInterface $input)
19
    {
20
        // This should return the name of your command.
21
        return 'tldr';
22
    }
23
24
    /**
25
     * Gets the default commands that should always be available.
26
     *
27
     * @return array An array of default Command instances
28
     */
29
    protected function getDefaultCommands()
30
    {
31
        // Keep the core default commands to have the HelpCommand
32
        // which is used when using the --help option
33
        $defaultCommands = parent::getDefaultCommands();
34
        $defaultCommands[] = new TldrCommand();
35
        return $defaultCommands;
36
    }
37
38
    /**
39
     * Overridden so that the application doesn't expect the command
40
     * name to be the first argument.
41
     */
42
    public function getDefinition()
43
    {
44
        $inputDefinition = parent::getDefinition();
45
        // clear out the normal first argument, which is the command name
46
        $inputDefinition->setArguments();
47
48
        return $inputDefinition;
49
    }
50
}
51