Module   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCachedServicesPath() 0 3 1
A registerAliases() 0 6 2
A registerProviders() 0 4 1
1
<?php
2
3
namespace Rawilk\LaravelModules\Laravel;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Foundation\AliasLoader;
7
use Illuminate\Foundation\ProviderRepository;
8
use Illuminate\Support\Str;
9
use Rawilk\LaravelModules\Module as BaseModule;
10
11
class Module extends BaseModule
12
{
13
    /**
14
     * Get the path to the cached *_module.php file.
15
     *
16
     * @return string
17
     */
18
    public function getCachedServicesPath(): string
19
    {
20
        return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->getCachedServicesPath());
21
    }
22
23
    public function registerAliases(): void
24
    {
25
        $loader = AliasLoader::getInstance();
26
27
        foreach ($this->get('aliases', []) as $aliasName => $aliasClass) {
28
            $loader->alias($aliasName, $aliasClass);
29
        }
30
    }
31
32
    public function registerProviders(): void
33
    {
34
        (new ProviderRepository($this->app, new Filesystem, $this->getCachedServicesPath()))
35
            ->load($this->get('providers', []));
36
    }
37
}
38