NotifierServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 66
c 1
b 0
f 0
wmc 3
lcom 1
cbo 3
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
A register() 0 20 1
A provides() 0 4 1
1
<?php namespace Cornford\Notifier\Providers;
2
3
4
use Cornford\Notifier\Listeners\AfterListener;
5
use Cornford\Notifier\Listeners\BeforeListener;
6
use Cornford\Notifier\Notifier;
7
use Illuminate\Support\ServiceProvider;
8
9
class NotifierServiceProvider extends ServiceProvider {
10
11
	/**
12
	 * Indicates if loading of the provider is deferred.
13
	 *
14
	 * @var boolean
15
	 */
16
	protected $defer = false;
17
18
	/**
19
	 * Bootstrap the application events.
20
	 *
21
	 * @return void
22
	 */
23
	public function boot(\Illuminate\Routing\Router $router)
24
	{
25
		$this->publishes(
26
			[
27
				__DIR__ . '/../../../config/config.php' => config_path('notifier.php'),
28
				__DIR__ . '/../../../../public' => public_path('packages/cornford/notifier')
29
			],
30
			'notifier'
31
		);
32
33
		$this->loadViewsFrom(__DIR__ . '/../../../views', 'notifier');
34
35
		include __DIR__ . '/../../../routes.php';
36
	}
37
38
	/**
39
	 * Register the service provider.
40
	 *
41
	 * @return void
42
	 */
43
	public function register()
44
	{
45
		$this->mergeConfigFrom(__DIR__ . '/../../../config/config.php', 'notifier');
46
47
		$this->app['router']->middleware('NotifierBeforeListener', 'Cornford\\Notifier\\Listeners\\BeforeListener');
48
		$this->app['router']->middleware('NotifierAfterListener', 'Cornford\\Notifier\\Listeners\\AfterListener');
49
50
		$this->app['router']->before(BeforeListener::class);
51
		$this->app['router']->after(AfterListener::class);
52
53
		$this->app->singleton(
54
            'notifier',
55
            function($app)
56
            {
57
                $config = $app['config']->get('notifier');
58
59
                return new Notifier($this->app->view, $this->app->{'session.store'}, $config);
0 ignored issues
show
Bug introduced by
Accessing view 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
            }
61
		);
62
	}
63
64
	/**
65
	 * Get the services provided by the provider.
66
	 *
67
	 * @return string[]
68
	 */
69
	public function provides()
70
	{
71
		return ['notifier'];
72
	}
73
74
}
75