Passed
Pull Request — master (#10)
by Anatoly
02:48
created

GenerateOpenApiDocumentCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A execute() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace App\Command;
4
5
/**
6
 * Import classes
7
 */
8
use App\ContainerAwareTrait;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * Import functions
15
 */
16
use function json_encode;
17
18
/**
19
 * Import constants
20
 */
21
use const JSON_UNESCAPED_SLASHES;
22
use const JSON_UNESCAPED_UNICODE;
23
24
/**
25
 * GenerateOpenApiDocumentCommand
26
 */
27
final class GenerateOpenApiDocumentCommand extends Command
28
{
29
    use ContainerAwareTrait;
30
31
    /**
32
     * {@inheritDoc}
33
     */
34 2
    protected function configure() : void
35
    {
36 2
        $this->setName('app:openapi:generate-document');
37 2
        $this->setDescription('Generates OpenApi document');
38 2
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43 1
    protected function execute(InputInterface $input, OutputInterface $output) : int
44
    {
45 1
        $flags = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE;
46
47 1
        $output->writeln(json_encode($this->container->get('openapi')->toArray(), $flags));
48
49 1
        return 0;
50
    }
51
}
52