HelpJsonHandler::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 12

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 17
loc 17
ccs 11
cts 11
cp 1
rs 9.4285
cc 2
eloc 12
nc 2
nop 3
crap 2
1
<?php
2
3
/*
4
 * This file is part of the webmozart/console package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webmozart\Console\Handler\Help;
13
14
use Symfony\Component\Console\Descriptor\JsonDescriptor;
15
use Webmozart\Console\Adapter\ApplicationAdapter;
16
use Webmozart\Console\Adapter\CommandAdapter;
17
use Webmozart\Console\Adapter\IOOutput;
18
use Webmozart\Console\Api\Args\Args;
19
use Webmozart\Console\Api\Command\Command;
20
use Webmozart\Console\Api\IO\IO;
21
22
/**
23
 * @since  1.0
24
 *
25
 * @author Bernhard Schussek <[email protected]>
26
 */
27 View Code Duplication
class HelpJsonHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32 6
    public function handle(Args $args, IO $io, Command $command)
33
    {
34 6
        $descriptor = new JsonDescriptor();
35 6
        $output = new IOOutput($io);
36 6
        $application = $command->getApplication();
37 6
        $applicationAdapter = new ApplicationAdapter($application);
38
39 6
        if ($args->isArgumentSet('command')) {
40 3
            $theCommand = $application->getCommand($args->getArgument('command'));
41 3
            $commandAdapter = new CommandAdapter($theCommand, $applicationAdapter);
42 3
            $descriptor->describe($output, $commandAdapter);
43
        } else {
44 3
            $descriptor->describe($output, $applicationAdapter);
45
        }
46
47 6
        return 0;
48
    }
49
}
50