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

MigrateAllCommand::getMigrationsConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
}