Passed
Pull Request — master (#5)
by Alexander
03:06
created

CycleMigrationConfig::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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
 * @method string getNamespace()
15
 * @method string getTable()
16
 * @method bool getSafe()
17
 */
18
class CycleMigrationConfig extends BaseConfig
19
{
20
    protected $directory = '@root/migrations';
21
    protected $namespace = 'App\\Migration';
22
    protected $table = 'migration';
23
    protected $safe = false;
24
25
    /** @var Aliases */
26
    private $objAliases;
27
28
    public function __construct(Aliases $aliases)
29
    {
30
        $this->objAliases = $aliases;
31
    }
32
33
    protected function getDirectory(): string
34
    {
35
        return $this->convertAlias($this->directory);
36
    }
37
38
    protected function convertAlias(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