Completed
Push — develop ( d73a05...7ce957 )
by Mike
07:24
created

ParseCommand::configure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 120

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 120
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Console\Command\Project;
17
18
use League\Pipeline\PipelineInterface;
19
use Symfony\Component\Console\Command\Command;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Input\InputOption;
22
use Symfony\Component\Console\Output\OutputInterface;
23
24
/**
25
 * Parses the given source code and creates a structure file.
26
 *
27
 * The parse task uses the source files defined either by -f or -d options and
28
 * generates a structure file (structure.xml) at the target location (which is
29
 * the folder 'output' unless the option -t is provided).
30
 */
31
final class ParseCommand extends Command
32
{
33
    /** @var PipelineInterface */
34
    private $pipeline;
35
36
    public function __construct(PipelineInterface $pipeline)
37
    {
38
        $this->pipeline = $pipeline;
39
40
        parent::__construct('project:parse');
41
    }
42
43
    /**
44
     * Initializes this command and sets the name, description, options and arguments.
45
     */
46
    protected function configure(): void
47
    {
48
        $this->setAliases(['parse'])
49
            ->setDescription('Creates a structure file from your source code')
50
            ->setHelp(<<<HELP
51
The parse task uses the source files defined either by -f or -d options and
52
generates cache files at the target location.
53
HELP
54
            )
55
            ->addOption(
56
                'filename',
57
                'f',
58
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
59
                'Comma-separated list of files to parse. The wildcards ? and * are supported'
60
            )
61
            ->addOption(
62
                'directory',
63
                'd',
64
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
65
                'Comma-separated list of directories to (recursively) parse'
66
            )
67
            ->addOption(
68
                'target',
69
                't',
70
                InputOption::VALUE_OPTIONAL,
71
                'Path where to store the cache (optional)'
72
            )
73
            ->addOption(
74
                'encoding',
75
                null,
76
                InputOption::VALUE_OPTIONAL,
77
                'Encoding to be used to interpret source files with'
78
            )
79
            ->addOption(
80
                'extensions',
81
                null,
82
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
83
                'Comma-separated list of extensions to parse, defaults to php, php3 and phtml'
84
            )
85
            ->addOption(
86
                'ignore',
87
                'i',
88
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
89
                'Comma-separated list of file(s) and directories that will be ignored. Wildcards * and ? '
90
                . 'are supported'
91
            )
92
            ->addOption(
93
                'ignore-tags',
94
                null,
95
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
96
                'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage '
97
                . 'and ignore may not be ignored.'
98
            )
99
            ->addOption(
100
                'hidden',
101
                null,
102
                InputOption::VALUE_NONE,
103
                'Use this option to tell phpDocumentor to parse files and directories that begin with a '
104
                . 'period (.), by default these are ignored'
105
            )
106
            ->addOption(
107
                'ignore-symlinks',
108
                null,
109
                InputOption::VALUE_NONE,
110
                'Ignore symlinks to other files or directories, default is on'
111
            )
112
            ->addOption(
113
                'markers',
114
                'm',
115
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
116
                'Comma-separated list of markers/tags to filter',
117
                ['TODO', 'FIXME']
118
            )
119
            ->addOption(
120
                'title',
121
                null,
122
                InputOption::VALUE_OPTIONAL,
123
                'Sets the title for this project; default is the phpDocumentor logo'
124
            )
125
            ->addOption(
126
                'force',
127
                null,
128
                InputOption::VALUE_NONE,
129
                'Forces a full build of the documentation, does not increment existing documentation'
130
            )
131
            ->addOption(
132
                'validate',
133
                null,
134
                InputOption::VALUE_NONE,
135
                'Validates every processed file using PHP Lint, costs a lot of performance'
136
            )
137
            ->addOption(
138
                'visibility',
139
                null,
140
                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
141
                'Specifies the parse visibility that should be displayed in the documentation (comma '
142
                . 'separated e.g. "public,protected")'
143
            )
144
            ->addOption(
145
                'sourcecode',
146
                null,
147
                InputOption::VALUE_NONE,
148
                'Whether to include syntax highlighted source code'
149
            )
150
            ->addOption(
151
                'parseprivate',
152
                null,
153
                InputOption::VALUE_NONE,
154
                'Whether to parse DocBlocks marked with @internal tag'
155
            )
156
            ->addOption(
157
                'defaultpackagename',
158
                null,
159
                InputOption::VALUE_OPTIONAL,
160
                'Name to use for the default package.',
161
                'Default'
162
            );
163
164
        parent::configure();
165
    }
166
167
    /**
168
     * Executes the business logic involved with this command.
169
     */
170
    protected function execute(InputInterface $input, OutputInterface $output): int
171
    {
172
        $pipeLine = $this->pipeline;
173
        $pipeLine($input->getOptions());
174
175
        return 0;
176
    }
177
}
178