CreateConfigCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Potievdev\SlimRbac\Console\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class CreateConfigCommand
11
 * @package Potievdev\SlimRbac\Command
12
 */
13
class CreateConfigCommand extends Command
14
{
15
    public function configure()
16
    {
17
        $this
18
            ->setName('create-config')
19
            ->setDescription('This command creates sr_config.yaml file in working directory');
20
    }
21
22
    /**
23
     * @param InputInterface $input
24
     * @param OutputInterface $output
25
     * @return void
26
     */
27
    public function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $configFile = file_get_contents(__DIR__ . '/../../../config/sr_config.example.yaml');
30
        $currentDir = getcwd();
31
        file_put_contents($currentDir . '/sr_config.yaml', $configFile);
32
        $output->writeln("File sr_config.yaml created in directory: $currentDir");
33
    }
34
}
35