ConfigCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
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