Completed
Pull Request — master (#3)
by Elf
02:53
created

AppsServiceProvider::setupAssets()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 4
cts 5
cp 0.8
crap 2.032
rs 9.4285
c 3
b 0
f 0
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