Completed
Push — master ( ab630c...316a2b )
by Elf
01:37
created

AppsServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
dl 0
loc 57
ccs 21
cts 21
cp 1
rs 10
c 4
b 0
f 0
wmc 6
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 2
A publishAssets() 0 6 1
A register() 0 9 1
A setupAssets() 0 8 2
1
<?php
2
3
namespace ElfSundae\Laravel\Apps;
4
5
use Illuminate\Support\ServiceProvider;
6
use Laravel\Lumen\Application as LumenApplication;
7
8
class AppsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the service provider.
12
     *
13
     * @return void
14
     */
15 2
    public function boot()
16
    {
17 2
        AppManager::registerMacros($this->app);
18
19 2
        if ($this->app->runningInConsole()) {
20 2
            $this->publishAssets();
21
        }
22 2
    }
23
24
    /**
25
     * Publish assets from package.
26
     *
27
     * @return void
28
     */
29 2
    protected function publishAssets()
30
    {
31 2
        $this->publishes([
32 2
            __DIR__.'/../config/apps.php' => base_path('config/apps.php'),
33 2
        ], 'laravel-apps');
34 2
    }
35
36
    /**
37
     * Register the service provider.
38
     *
39
     * @return void
40
     */
41 2
    public function register()
42
    {
43 2
        $this->setupAssets();
44
45 2
        $this->app->singleton('apps', function ($app) {
46 1
            return new AppManager($app);
47 2
        });
48 2
        $this->app->alias('apps', AppManager::class);
49 2
    }
50
51
    /**
52
     * Setup package assets.
53
     *
54
     * @return void
55
     */
56 2
    protected function setupAssets()
57
    {
58 2
        if ($this->app instanceof LumenApplication) {
59
            $this->app->configure('apps'); // @codeCoverageIgnore
60
        }
61
62 2
        $this->mergeConfigFrom(__DIR__.'/../config/apps.php', 'apps');
63 2
    }
64
}
65