Completed
Push — master ( b4fb45...fd4491 )
by dima
02:45
created

InstallPackagesCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 31
rs 10

2 Methods

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