Completed
Push — master ( dc322e...438d0e )
by Mahmoud
03:27
created

AutoLoaderTrait::runLoadersRegister()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace App\Ship\Engine\Loaders;
4
5
use App\Ship\Engine\Butlers\Facades\LoaderButler;
6
7
/**
8
 * Class AutoLoaderTrait.
9
 *
10
 * @author  Mahmoud Zalt <[email protected]>
11
 */
12
trait AutoLoaderTrait
13
{
14
15
    // using each component loader trait
16
    use ConfigsLoaderTrait;
17
    use MigrationsLoaderTrait;
18
    use ViewsLoaderTrait;
19
    use ProvidersLoaderTrait;
20
    use ConsolesLoaderTrait;
21
    use AliasesLoaderTrait;
22
23
    /**
24
     * * to be used from the `boot` function of the main service provider
25
     */
26
    public function runLoadersBoot()
27
    {
28
        // the config files should be loaded first from all the directories in their own loop
29
        $this->loadConfigsFromShip();
30
        $this->loadProvidersFromShip();
31
32
        // > iterate over all the port folders and autoload most of the components
33
        foreach (LoaderButler::getShipFoldersNames() as $portFolderName) {
34
            $this->loadMigrationsFromShip();
35
            $this->loadViewsFromShip($portFolderName);
36
        }
37
38
        // > iterate over all the containers folders and autoload most of the components
39
        foreach (LoaderButler::getContainersNames() as $containerName) {
40
            $this->loadConfigsFromContainers($containerName);
41
            $this->loadProvidersFromContainers($containerName);
42
            $this->loadMigrationsFromContainers($containerName);
43
            $this->loadViewsFromContainers($containerName);
44
            $this->loadViewsFromContainers($containerName);
45
            $this->loadConsolesFromContainers($containerName);
46
        }
47
    }
48
49
    /**
50
     * to be used from the `register` function of the main service provider
51
     */
52
    public function runLoadersRegister()
53
    {
54
        $this->loadContainerFactories();
0 ignored issues
show
Bug introduced by
It seems like loadContainerFactories() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
55
        $this->loadShipInternalAliases();
56
    }
57
58
}
59