PrepareRouteFilesCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Bugloos\ApiVersioningBundle\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
class PrepareRouteFilesCommand extends Command
10
{
11
    protected static $defaultName = 'api-versioning:prepare-route-files';
12
13
    private array $nextVersions;
14
15
    public function __construct(array $nextVersions,string $name = null)
16
    {
17
        parent::__construct($name);
18
        $this->nextVersions = $nextVersions;
19
    }
20
21
    protected function configure(): void
22
    {
23
        $this->setDescription('Prepare route configs files');
24
    }
25
26
    /**
27
     * @param InputInterface $input
28
     * @param OutputInterface $output
29
     *
30
     * @return int
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        foreach ($this->nextVersions as $version) {
35
            $filePath = sprintf('%s/config/routes/routes_%s.yaml', getcwd(), $version);
36
            fopen($filePath, 'w');
37
        }
38
39
        return 0;
40
    }
41
}
42