Application::getDefaultCommands()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
/**
4
 * Application
5
 *
6
 * PHP Version 5.3.0
7
 *
8
 * Copyright (c) 2007-2014, Mayflower GmbH
9
 * All rights reserved.
10
 *
11
 * Redistribution and use in source and binary forms, with or without
12
 * modification, are permitted provided that the following conditions
13
 * are met:
14
 *
15
 *   * Redistributions of source code must retain the above copyright
16
 *     notice, this list of conditions and the following disclaimer.
17
 *
18
 *   * Redistributions in binary form must reproduce the above copyright
19
 *     notice, this list of conditions and the following disclaimer in
20
 *     the documentation and/or other materials provided with the
21
 *     distribution.
22
 *
23
 *   * Neither the name of Mayflower GmbH nor the names of his
24
 *     contributors may be used to endorse or promote products derived
25
 *     from this software without specific prior written permission.
26
 *
27
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
 * POSSIBILITY OF SUCH DAMAGE.
39
 *
40
 * @category PHP_CodeBrowser
41
 *
42
 * @author Robin Gloster <[email protected]>
43
 *
44
 * @copyright 2007-2010 Mayflower GmbH
45
 *
46
 * @license http://www.opensource.org/licenses/bsd-license.php  BSD License
47
 *
48
 * @version SVN: $Id$
49
 *
50
 * @link http://www.phpunit.de/
51
 *
52
 * @since File available since 1.1
53
 */
54
55
namespace PHPCodeBrowser;
56
57
use PHPCodeBrowser\Command\RunCommand;
58
use Symfony\Component\Console\Application as BaseApplication;
59
use Symfony\Component\Console\Command\Command;
60
use Symfony\Component\Console\Input\InputDefinition;
61
use Symfony\Component\Console\Input\InputInterface;
62
63
/**
64
 * Class Application
65
 */
66
class Application extends BaseApplication
67
{
68
    /**
69
     * Gets the InputDefinition related to this Application.
70
     *
71
     * @return InputDefinition The InputDefinition instance
72
     */
73
    public function getDefinition(): InputDefinition
74
    {
75
        $inputDefinition = parent::getDefinition();
76
        // clear out the normal first argument, which is the command name
77
        $inputDefinition->setArguments();
78
79
        return $inputDefinition;
80
    }
81
82
    /**
83
     * Gets the name of the command based on input.
84
     *
85
     * @param InputInterface $input
86
     *
87
     * @phpcs:disable SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
88
     *
89
     * @return string The command name
90
     */
91
    protected function getCommandName(InputInterface $input): string
92
    {
93
        return 'phpcb';
94
    }
95
96
    /**
97
     * Gets the default commands that should always be available.
98
     *
99
     * @return array<Command> An array of default Command instances
100
     */
101
    protected function getDefaultCommands(): array
102
    {
103
        // Adds HelpCommand for --help
104
        $defaultCommands = parent::getDefaultCommands();
105
106
        $defaultCommands[] = new RunCommand();
107
108
        return $defaultCommands;
109
    }
110
}
111