Passed
Pull Request — master (#5)
by
unknown
01:34
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 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
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-read string $directory
11
 * @property-read string $namespace
12
 * @property-read string $table
13
 * @property-read bool   $safe
14
 */
15
class MigrationConfig extends BaseConfig
16
{
17
    protected $directory = '@root/migrations';
18
    protected $namespace = 'App\\Migration';
19
    protected $table = 'migration';
20
    protected $safe = false;
21
22
    /** @var Aliases */
23
    private $objAliases;
24
25
    public function __construct(Params $params, Aliases $aliases)
26
    {
27
        $this->objAliases = $aliases;
28
        parent::__construct($params);
29
    }
30
31
    protected function getDirectory(): string
32
    {
33
        return $this->getAlias($this->directory);
34
    }
35
36
    protected function getAlias(string $alias): string
37
    {
38
        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...
39
    }
40
}
41