Completed
Push — master ( 31b0e8...f745f1 )
by Mahmoud
06:12
created

AliasesLoaderTrait::loadAliasesFromShip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Ship\Engine\Loaders;
4
5
use App;
6
use Illuminate\Foundation\AliasLoader;
7
8
/**
9
 * Class AliasesLoaderTrait.
10
 *
11
 * @author  Mahmoud Zalt <[email protected]>
12
 */
13
trait AliasesLoaderTrait
14
{
15
16
    /**
17
     * @void
18
     */
19
    public function loadAliases()
20
    {
21
        // `$this->aliases` is declared on each Container's Main Service Provider
22
        foreach (isset($this->aliases) ? $this->aliases : [] as $aliasKey => $aliasValue) {
0 ignored issues
show
Bug introduced by
The property aliases 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...
23
            if (class_exists($aliasValue)) {
24
                $this->loadAlias($aliasKey, $aliasValue);
25
            }
26
        }
27
    }
28
29
    /**
30
     * @param $aliasKey
31
     * @param $aliasValue
32
     */
33
    private function loadAlias($aliasKey, $aliasValue)
34
    {
35
        AliasLoader::getInstance()->alias($aliasKey, $aliasValue);
36
    }
37
}
38