MakeRequest::getCommandDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace MojtabaGheytasi\RequestValidatorBundle\Maker;
4
5
use Symfony\Bundle\MakerBundle\ConsoleStyle;
6
use Symfony\Bundle\MakerBundle\DependencyBuilder;
7
use Symfony\Bundle\MakerBundle\Generator;
8
use Symfony\Bundle\MakerBundle\InputConfiguration;
9
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\InputArgument;
12
use Symfony\Component\Console\Input\InputInterface;
13
14
class MakeRequest extends AbstractMaker
15
{
16
    public static function getCommandName(): string
17
    {
18
        return 'make:request';
19
    }
20
21
    public static function getCommandDescription(): string
22
    {
23
        return 'Creates a request validation class';
24
    }
25
26
    public function configureCommand(Command $command, InputConfiguration $inputConfig)
27
    {
28
        $command
29
            ->setDescription(self::getCommandDescription())
30
            ->addArgument('name', InputArgument::REQUIRED, 'The name of the request validation class (e.g. <fg=yellow>ExampleRequest</>)');
31
32
        $inputConfig->setArgumentAsNonInteractive('name');
33
    }
34
35
    public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
36
    {
37
        $storyClassNameDetails = $generator->createClassNameDetails(
38
            $input->getArgument('name'),
39
            'Request',
40
            'Request'
41
        );
42
43
        $generator->generateClass(
44
            $storyClassNameDetails->getFullName(),
45
            __DIR__.'/../Resources/skeleton/Request.tpl.php',
46
            []
47
        );
48
49
        $generator->writeChanges();
50
51
        $this->writeSuccessMessage($io);
52
53
        $io->text([
54
            'Next: Open your request class and write your constraints.',
55
            'Find the documentation at https://github.com/mojtaba-gheytasi/request-validator-bundle#readme',
56
        ]);
57
    }
58
59
    public function configureDependencies(DependencyBuilder $dependencies)
60
    {
61
    }
62
}
63