AlerterServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 7 1
A provides() 0 4 1
1
<?php namespace Cornford\Alerter;
2
3
use Illuminate\Support\ServiceProvider;
4
use Cornford\Alerter\Alert;
5
6
class AlerterServiceProvider extends ServiceProvider {
7
8
	/**
9
	 * Indicates if loading of the provider is deferred.
10
	 *
11
	 * @var bool
12
	 */
13
	protected $defer = true;
14
15
	/**
16
	 * Bootstrap the application events.
17
	 *
18
	 * @return void
19
	 */
20
	public function boot()
21
	{
22
		$this->package('cornford/alerter');
0 ignored issues
show
Documentation Bug introduced by
The method package does not exist on object<Cornford\Alerter\AlerterServiceProvider>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
23
	}
24
25
	/**
26
	 * Register the service provider.
27
	 *
28
	 * @return void
29
	 */
30
	public function register()
31
	{
32
		$this->app->bind('alert', function()
33
		{
34
			return Alert::create(Alert::TYPE_NONE, '');
35
		});
36
	}
37
38
	/**
39
	 * Get the services provided by the provider.
40
	 *
41
	 * @return array
42
	 */
43
	public function provides()
44
	{
45
		return array('alert');
46
	}
47
48
}
49