Completed
Pull Request — master (#37)
by Anton
06:21
created

AliasTrait::resolveAlias()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 3
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Core\Traits\Config;
9
10
/**
11
 * Provides aliasing ability for config classes
12
 */
13
trait AliasTrait
14
{
15
    /**
16
     * @param string $alias
17
     * @return string
18
     */
19
    public function resolveAlias($alias)
20
    {
21
        while (is_string($alias) && isset($this->config['aliases'][$alias])) {
1 ignored issue
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
            //Resolving database alias
23
            $alias = $this->config['aliases'][$alias];
24
        }
25
26
        return $alias;
27
28
    }
29
}