InstallPackagesCommand::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 3
eloc 12
nc 3
nop 2
1
<?php
2
namespace Frameworkless\Console\Commands;
3
4
use Symfony\Component\Console\Command\Command;
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
/**
9
 * Description of HelloWorldCommand
10
 *
11
 * @author Dmitriy
12
 */
13
class InstallPackagesCommand extends Command{
14
15
    protected function configure(){
16
	$this->setName('packages:install')
17
		->setDescription('Install packages migration and assets');
18
    }
19
20
    protected function execute(InputInterface $input, OutputInterface $output){
21
	$finder = \Symfony\Component\Finder\Finder::create();
22
23
	$root_path = __DIR__ . "../../../..";
24
25
	$iterator = $finder
26
		->files()
27
		->in($root_path . "/vendor/*/*/db");
28
29
	foreach($iterator as $file){
30
31
	    if(!copy($file->getRealpath(), $root_path . '/db/' . $file->getRelativePathname())){
32
		$output->writeln(sprintf("error copy migration %s...", $file->getRelativePathname()));
33
	    } else{
34
		$output->writeln(sprintf("copy migration %s", $file->getRelativePathname()));
35
	    }
36
	}
37
38
	$output->writeln("completed!");
39
    }
40
}
41