Completed
Push — master ( 8fb423...c81d0e )
by
unknown
04:06
created

MigrateAllCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 52
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMigrateCommand() 0 4 1
A getMigrationsConfig() 0 4 1
A __invoke() 0 9 2
1
<?php
2
/**
3
 * Reddogs (https://github.com/reddogs-at)
4
 *
5
 * @see https://github.com/reddogs-at/reddogs-doctrine-migrations for the canonical source repository
6
 * @license https://github.com/reddogs-at/reddogs-doctrine-migrations/blob/master/LICENSE MIT License
7
 */
8
namespace Reddogs\Doctrine\Migrations;
9
10
use Zend\Console\Adapter\AdapterInterface;
11
use ZF\Console\Route;
12
13
class MigrateAllCommand
14
{
15
    /**
16
     * Migrate command
17
     *
18
     * @var MigrateCommand
19
     */
20
    private $migrateCommand;
21
22
    /**
23
     * Migrations config 
24
     * 
25
     * @var array
26
     */
27
    private $migrationsConfig;
28
29
    public function __construct(MigrateCommand $migrateCommand, array $migrationsConfig)
30
    {
31
        $this->migrateCommand = $migrateCommand;
32
        $this->migrationsConfig = $migrationsConfig;
33
    }
34
35
    /**
36
     * Get migrate command
37
     *
38
     * @return MigrateCommand
39
     */
40
    public function getMigrateCommand()
41
    {
42
        return $this->migrateCommand;
43
    }
44
45
    /**
46
     * Get migrations config 
47
     *
48
     * @return array
49
     */
50
    public function getMigrationsConfig()
51
    {
52
        return $this->migrationsConfig;
53
    }
54
55
    public function __invoke(Route $route, AdapterInterface $console)
56
    {
57
        foreach ($this->getMigrationsConfig() as $key => $params)
58
        {
59
            $migrateCommand = $this->getMigrateCommand();
60
            $migrateRoute = new Route('migrations:migrate', 'migrations:migrate ' . $key);
61
            $migrateCommand($migrateRoute, $console);
62
        }
63
    }
64
}