Passed
Push — master ( 565c26...461f06 )
by Aleksei
02:34
created

MigrationConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license MIT
7
 * @author  Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Migrations\Config;
13
14
use Spiral\Core\InjectableConfig;
15
16
final class MigrationConfig extends InjectableConfig
17
{
18
    /**
19
     * @internal This is an internal config section name. Please, do not use
20
     *           this constant.
21
     */
22
    public const CONFIG = 'migration';
23
24
    /**
25
     * @param array{directory?: string|null, table?: string|null, safe?: bool|null} $config
26
     */
27
    public function __construct(array $config = [])
28
    {
29
        parent::__construct($config);
30
    }
31
32
    /**
33
     * Migrations directory.
34
     *
35
     * @return string
36
     */
37
    public function getDirectory(): string
38
    {
39
        return $this->config['directory'] ?? '';
40
    }
41
42
    /**
43
     * Table to store list of executed migrations.
44
     *
45
     * @return string
46
     */
47
    public function getTable(): string
48
    {
49
        return $this->config['table'] ?? 'migrations';
50
    }
51
52
    /**
53
     * Is it safe to run migration without user confirmation? Attention, this option does not
54
     * used in component directly and left for component consumers.
55
     *
56
     * @return bool
57
     */
58
    public function isSafe(): bool
59
    {
60
        return $this->config['safe'] ?? false;
61
    }
62
63
    /**
64
     * Namespace for generated migration class
65
     *
66
     * @return string
67
     */
68
    public function getNamespace(): string
69
    {
70
        return $this->config['namespace'] ?? 'Migration';
71
    }
72
}
73