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

ConfigCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 15
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A perform() 0 8 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\ConfigDeclaration;
12
13
#[AsCommand(name: 'create:config', description: 'Create config declaration')]
14
class ConfigCommand extends AbstractCommand
15
{
16
    #[Argument(description: 'Сonfig name, or a config filename if "-r" flag is set ({path/to/configs/directory/}{config/filename}.php)')]
17
    #[Question(question: 'Please provide the name of the Config class, or the filename of an existing config file')]
18
    private string $name;
19
20
    #[Option(shortcut: 'r', description: 'Create config class based on a given config filename')]
21
    private bool $reverse = false;
22
23
    #[Option(shortcut: 'c', description: 'Optional comment to add as class header')]
24
    private ?string $comment = null;
0 ignored issues
show
introduced by
The private property $comment is not used, and could be removed.
Loading history...
25
26
    #[Option(description: 'Optional, specify a custom namespace')]
27
    private ?string $namespace = null;
0 ignored issues
show
introduced by
The private property $namespace is not used, and could be removed.
Loading history...
28
29 7
    public function perform(): int
30
    {
31 7
        $declaration = $this->createDeclaration(ConfigDeclaration::class);
32 7
        $declaration->create($this->reverse, $this->name);
0 ignored issues
show
Bug introduced by
The method create() does not exist on Spiral\Scaffolder\Declaration\DeclarationInterface. It seems like you code against a sub-type of Spiral\Scaffolder\Declaration\DeclarationInterface such as Spiral\Scaffolder\Declaration\ConfigDeclaration. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $declaration->/** @scrutinizer ignore-call */ 
33
                      create($this->reverse, $this->name);
Loading history...
33
34 7
        $this->writeDeclaration($declaration);
35
36 7
        return self::SUCCESS;
37
    }
38
}
39