Completed
Pull Request — master (#6)
by Elf
01:13
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

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
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 2
    public function boot()
16
    {
17 2
        $this->registerMacros();
18
19 2
        if ($this->app->runningInConsole()) {
20 2
            $this->publishAssets();
21
        }
22 2
    }
23
24
    /**
25
     * Register macros.
26
     *
27
     * @return void
28
     */
29
    protected function registerMacros()
30
    {
31 2
        $this->app['url']->macro('getRootControllerNamespace', function () {
32
            /* @var $this \Illuminate\Routing\UrlGenerator */
33 1
            return $this->rootNamespace;
34 2
        });
35 2
    }
36
37
    /**
38
     * Publish assets from package.
39
     *
40
     * @return void
41
     */
42 2
    protected function publishAssets()
43
    {
44 2
        $this->publishes([
45 2
            __DIR__.'/../config/apps.php' => base_path('config/apps.php'),
46 2
        ], 'laravel-apps');
47 2
    }
48
49
    /**
50
     * Register the service provider.
51
     *
52
     * @return void
53
     */
54 2
    public function register()
55
    {
56 2
        $this->setupAssets();
57
58 2
        $this->app->singleton('apps', function ($app) {
59 1
            return new AppManager($app);
60 2
        });
61 2
        $this->app->alias('apps', AppManager::class);
62 2
    }
63
64
    /**
65
     * Setup package assets.
66
     *
67
     * @return void
68
     */
69 2
    protected function setupAssets()
70
    {
71 2
        if ($this->app instanceof LumenApplication) {
0 ignored issues
show
Bug introduced by
The class Laravel\Lumen\Application does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
72
            $this->app->configure('apps'); // @codeCoverageIgnore
73
        }
74
75 2
        $this->mergeConfigFrom(__DIR__.'/../config/apps.php', 'apps');
76 2
    }
77
}
78