ConfigCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A perform() 0 10 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Spiral\Command;
6
7
use Spiral\Boot\DirectoriesInterface;
8
use Spiral\Console\Attribute\AsCommand;
9
use Spiral\Console\Command;
10
use Spiral\Files\FilesInterface;
11
12
#[AsCommand(
13
    name: 'graphql:config',
14
    description: 'Create GraphQL config with default values',
15
    help: 'Dump default values into config/graphql.php file',
16
)]
17
final class ConfigCommand extends Command
18
{
19 1
    public function __construct(
20
        private readonly FilesInterface $files,
21
        private readonly DirectoriesInterface $dirs,
22
    ) {
23 1
        parent::__construct();
24
    }
25
26 1
    public function perform(): int
27
    {
28 1
        $this->info(sprintf('Create default configuration into: %sgraphql.php', $this->dirs->get('config')));
29
30 1
        $source = __DIR__ . '/../../config/graphql.php.sample';
31 1
        $destination = $this->dirs->get('config') . 'graphql.php';
32
33 1
        $this->files->copy($source, $destination);
34
35 1
        return self::SUCCESS;
36
    }
37
}
38