Completed
Pull Request — master (#758)
by Nicolas
03:30
created

Migrator::setDatabase()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules\Migrations;
4
5
use Nwidart\Modules\Module;
6
use Nwidart\Modules\Support\Config\GenerateConfigReader;
7
8
class Migrator
9
{
10
    /**
11
     * Nwidart Module instance.
12
     * @var Module
13
     */
14
    private $module;
15
16
    /**
17
     * Create new instance.
18
     * @param Module $module
19
     */
20 1
    public function __construct(Module $module)
21
    {
22 1
        $this->module = $module;
23 1
    }
24
25
    /**
26
     * @return Module
27
     */
28 1
    public function getModule()
29
    {
30 1
        return $this->module;
31
    }
32
33
    /**
34
     * Get migration path.
35
     * @return string
36
     */
37 1
    public function getPath(): string
38
    {
39 1
        $config = $this->module->get('migration');
40
41 1
        $migrationPath = GenerateConfigReader::read('migration');
42 1
        $path = (is_array($config) && array_key_exists('path', $config)) ? $config['path'] : $migrationPath->getPath();
43
44 1
        return $this->module->getExtraPath($path);
45
    }
46
}
47