Passed
Pull Request — master (#5)
by
unknown
03:01
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 Yiisoft\Aliases\Aliases;
6
use Yiisoft\Yii\Cycle\Config\BaseConfig;
7
use Yiisoft\Yii\Cycle\Config\Params;
8
9
/**
10
 * @property string $directory
11
 * @property string $namespace
12
 * @property string $table
13
 * @property bool   $safe
14
 */
15
class MigrationConfig extends BaseConfig
16
{
17
    protected $data = [
18
        'directory' => '@root/migrations',
19
        'namespace' => 'App\\Migration',
20
        'table'     => 'migration',
21
        'safe'      => false,
22
    ];
23
24
    /** @var Aliases */
25
    private $objAliases;
26
27
    public function __construct(Params $params, Aliases $aliases)
28
    {
29
        $this->objAliases = $aliases;
30
        parent::__construct($params);
31
    }
32
33
    protected function getDirectory(): string
34
    {
35
        return $this->getAlias($this->data['directory']);
36
    }
37
38
    protected function getAlias(string $alias): string
39
    {
40
        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...
41
    }
42
}
43