Passed
Pull Request — master (#927)
by Aleksei
08:21
created

MiddlewareCommand::perform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Scaffolder\Command;
6
7
use Spiral\Console\Attribute\Argument;
8
use Spiral\Console\Attribute\AsCommand;
9
use Spiral\Console\Attribute\Option;
10
use Spiral\Console\Attribute\Question;
11
use Spiral\Scaffolder\Declaration\MiddlewareDeclaration;
12
13
#[AsCommand(name: 'create:middleware', description: 'Create middleware declaration')]
14
class MiddlewareCommand extends AbstractCommand
15
{
16
    #[Argument(description: 'Middleware name')]
17
    #[Question(question: 'What would you like to name the Middleware?')]
18
    private string $name;
0 ignored issues
show
introduced by
The private property $name is not used, and could be removed.
Loading history...
19
20
    #[Option(shortcut: 'c', description: 'Optional comment to add as class header')]
21
    private ?string $comment = null;
0 ignored issues
show
introduced by
The private property $comment is not used, and could be removed.
Loading history...
22
23
    #[Option(description: 'Optional, specify a custom namespace')]
24
    private ?string $namespace = null;
0 ignored issues
show
introduced by
The private property $namespace is not used, and could be removed.
Loading history...
25
26 2
    public function perform(): int
27
    {
28 2
        $declaration = $this->createDeclaration(MiddlewareDeclaration::class);
29
30 2
        $this->writeDeclaration($declaration);
31
32 2
        return self::SUCCESS;
33
    }
34
}
35