TldrApplication::getDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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\ArgvInput;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class TldrApplication extends Application
12
{
13
    /**
14
     * Gets the name of the command based on input.
15
     *
16
     * @param InputInterface $input The input interface
17
     *
18
     * @return string The command name
19
     */
20
    protected function getCommandName(InputInterface $input)
21
    {
22
        // This should return the name of your command.
23
        return 'tldr';
24
    }
25
26
    /**
27
     * Gets the default commands that should always be available.
28
     *
29
     * @return array An array of default Command instances
30
     */
31
    protected function getDefaultCommands()
32
    {
33
        // Keep the core default commands to have the HelpCommand
34
        // which is used when using the --help option
35
        $defaultCommands = parent::getDefaultCommands();
36
        $defaultCommands[] = new TldrCommand();
37
        return $defaultCommands;
38
    }
39
40
    /**
41
     * Overridden so that the application doesn't expect the command
42
     * name to be the first argument.
43
     */
44
    public function getDefinition()
45
    {
46
        $inputDefinition = parent::getDefinition();
47
        // clear out the normal first argument, which is the command name
48
        $inputDefinition->setArguments();
49
50
        return $inputDefinition;
51
    }
52
}
53