Passed
Pull Request — master (#5)
by
unknown
01:46
created

MigrationConfig::getDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Yiisoft\Yii\Cycle;
4
5
use Spiral\Database\Config\DatabaseConfig;
6
use Yiisoft\Aliases\Aliases;
7
use Yiisoft\Yii\Cycle\Config\BaseConfig;
8
use Yiisoft\Yii\Cycle\Config\Params;
9
10
/**
11
 * Class CommonConfig
12
 * @package Yiisoft\Yii\Cycle\Config
13
 *
14
 * @property string $directory
15
 * @property string $namespace
16
 * @property string $table
17
 * @property bool   $safe
18
 */
19
class MigrationConfig extends BaseConfig
20
{
21
    protected $data = [
22
        'directory' => '@root/migrations',
23
        'namespace' => 'App\\Migration',
24
        'table'     => 'migration',
25
        'safe'      => false,
26
    ];
27
28
    /** @var Aliases */
29
    private $objAliases;
30
31
    public function __construct(Params $params, Aliases $aliases)
32
    {
33
        $this->objAliases = $aliases;
34
        parent::__construct($params);
35
    }
36
37
    protected function getDirectory(): string
38
    {
39
        return $this->getAlias($this->data['directory']);
40
    }
41
42
    protected function getAlias(string $alias): string
43
    {
44
        return $this->objAliases->get($alias, true);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->objAliases->get($alias, true) could return the type boolean which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
45
    }
46
}
47