Completed
Push — master ( 766f26...9e4e10 )
by Elf
11s
created

AppsServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 95.45%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A publishAssets() 0 6 1
A boot() 0 6 2
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 1
    public function boot()
16
    {
17 1
        if ($this->app->runningInConsole()) {
18 1
            $this->publishAssets();
19 1
        }
20 1
    }
21
22
    /**
23
     * Publish assets from package.
24
     *
25
     * @return void
26
     */
27 1
    protected function publishAssets()
28
    {
29 1
        $this->publishes([
30 1
            __DIR__.'/../config/apps.php' => base_path('config/apps.php'),
31 1
        ], 'laravel-apps');
32 1
    }
33
34
    /**
35
     * Register the service provider.
36
     *
37
     * @return void
38
     */
39 1
    public function register()
40
    {
41 1
        $this->setupAssets();
42
43 1
        $this->app->singleton('apps', function ($app) {
44 1
            return new Apps($app);
45 1
        });
46 1
        $this->app->alias('apps', Apps::class);
47 1
    }
48
49
    /**
50
     * Setup package assets.
51
     *
52
     * @return void
53
     */
54 1
    protected function setupAssets()
55
    {
56 1
        if ($this->app instanceof LumenApplication) {
57
            $this->app->configure('apps'); // @codeCoverageIgnore
58
        }
59
60 1
        $this->mergeConfigFrom(__DIR__.'/../config/apps.php', 'apps');
61 1
    }
62
}
63