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

CycleMigrationConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 23
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDirectory() 0 3 1
A __construct() 0 3 1
A convertAlias() 0 3 1
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