Passed
Push — master ( f23efe...b78b4c )
by Elf
03:51
created

AppsServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 95%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 53
ccs 19
cts 20
cp 0.95
rs 10
c 3
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A boot() 0 4 2
A publishAssets() 0 5 1
A setupAssets() 0 12 3
1
<?php
2
3
namespace ElfSundae\Laravel\Apps;
4
5
use Illuminate\Support\ServiceProvider;
6
use Laravel\Lumen\Application as LumenApplication;
0 ignored issues
show
Bug introduced by
The type Laravel\Lumen\Application was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class AppsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the service provider.
12
     *
13
     * @return void
14
     */
15 3
    public function boot()
16
    {
17 3
        if ($this->app->runningInConsole()) {
18 3
            $this->publishAssets();
19
        }
20 3
    }
21
22
    /**
23
     * Publish assets from package.
24
     *
25
     * @return void
26
     */
27 3
    protected function publishAssets()
28
    {
29 3
        $this->publishes([
30 3
            __DIR__.'/../config/apps.php' => base_path('config/apps.php'),
31 3
        ], 'laravel-apps');
32 3
    }
33
34
    /**
35
     * Register the service provider.
36
     *
37
     * @return void
38
     */
39 3
    public function register()
40
    {
41 3
        $this->setupAssets();
42 3
    }
43
44
    /**
45
     * Setup package assets.
46
     *
47
     * @return void
48
     */
49 3
    protected function setupAssets()
50
    {
51 3
        if ($this->app instanceof LumenApplication) {
52
            $this->app->configure('apps');
53
        }
54
55 3
        $this->mergeConfigFrom(__DIR__.'/../config/apps.php', 'apps');
56
57 3
        if (! $this->app['config']->has('apps.domain')) {
58 3
            $this->app['config']['apps.domain'] = array_map(function ($url) {
59 3
                return parse_url($url, PHP_URL_HOST);
60 3
            }, $this->app['config']['apps.url']);
61
        }
62 3
    }
63
}
64