BlueServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 7
b 0
f 0
nc 1
nop 0
dl 0
loc 23
rs 9.0856
1
<?php
2
3
namespace MeestorHok\Blue;
4
5
use Illuminate\Support\ServiceProvider;
6
use Form;
7
8
class BlueServiceProvider extends ServiceProvider
9
{
10
    
11
    /**
12
     * Perform post-registration booting of services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->loadViewsFrom(__DIR__.'/resources/views', 'Blue');
19
        
20
        $this->publishes([
21
            __DIR__.'/resources/public' => public_path('blue'),
22
        ], 'frontend');
23
        
24
        $this->publishes([
25
            __DIR__.'/Migrations' => database_path('migrations'),
26
        ], 'migrations');
27
        
28
        $this->publishes([
29
            __DIR__.'/Http/routes.blue.php' => app_path('Http/routes.blue.php'),
30
            __DIR__.'/Http/routes.php' => app_path('Http/routes.php'),
31
        ], 'routes');
32
        
33
        Form::component('blueText', 'Blue::components.text', ['name', 'attributes' => []]);
34
        Form::component('blueEmail', 'Blue::components.email', ['name', 'attributes' => []]);
35
        Form::component('blueToggle', 'Blue::components.toggle', ['name', 'value' => null, 'checked' => false, 'attributes' => []]);
36
        Form::component('blueTextarea', 'Blue::components.textarea', ['name', 'attributes' => []]);
37
        Form::component('bluePassword', 'Blue::components.password', ['name', 'attributes' => []]);
38
    }
39
40
    /**
41
     * Register any package services.
42
     *
43
     * @return void
44
     */
45
    public function register()
46
    {
47
        $this->app->bind('SEO', function() {
48
            return new \MeestorHok\Blue\SEOGenerator;
49
        });
50
        
51
        require app_path('Http/routes.blue.php');
52
        require_once(__DIR__.'/helpers.php');
53
        
54
        $this->app->register('Collective\Html\HtmlServiceProvider');
55
        $this->app->register('Artesaos\SEOTools\Providers\SEOToolsServiceProvider');
56
        
57
        $this->app->router->middleware('siteExists', \MeestorHok\Blue\Http\Middleware\SiteExistsMiddleware::class);
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
58
        $this->app->router->middleware('siteDoesntExist', \MeestorHok\Blue\Http\Middleware\SiteDoesntExistMiddleware::class);
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
59
        $this->app->router->middleware('adminExists', \MeestorHok\Blue\Http\Middleware\AdminExistsMiddleware::class);
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
60
        $this->app->router->middleware('adminDoesntExist', \MeestorHok\Blue\Http\Middleware\AdminDoesntExistMiddleware::class);
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
61
        
62
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
63
        $loader->alias('Html', 'Collective\Html\HtmlFacade');
64
        $loader->alias('Form', 'Collective\Html\FormFacade');
65
        $loader->alias('SEO', 'MeestorHok\Blue\Facades\SEOFacade');
66
    }
67
}
68