Passed
Push — master ( 865ea9...f5a1ef )
by butschster
29:08 queued 21:20
created

MiddlewareCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 20
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A perform() 0 7 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