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

MigrationConfig::__construct()   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 3
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 3
b 0
f 1
nc 1
nop 1
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
8
/**
9
 * @property-read string $directory
10
 * @property-read string $namespace
11
 * @property-read string $table
12
 * @property-read bool   $safe
13
 */
14
class MigrationConfig extends BaseConfig
15
{
16
    protected $directory = '@root/migrations';
17
    protected $namespace = 'App\\Migration';
18
    protected $table = 'migration';
19
    protected $safe = false;
20
21
    /** @var Aliases */
22
    private $objAliases;
23
24
    public function __construct(Aliases $aliases)
25
    {
26
        $this->objAliases = $aliases;
27
    }
28
29
    protected function getDirectory(): string
30
    {
31
        return $this->convertAlias($this->directory);
32
    }
33
34
    protected function convertAlias(string $alias): string
35
    {
36
        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...
37
    }
38
}
39