AnalyticsServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 1
A register() 0 14 1
A provides() 0 4 1
1
<?php namespace Cornford\Googlitics;
2
3
use Illuminate\Support\ServiceProvider;
4
use Illuminate\Support\Facades\Config;
5
6
class AnalyticsServiceProvider extends ServiceProvider {
7
8
	/**
9
	 * Indicates if loading of the provider is deferred.
10
	 *
11
	 * @var bool
12
	 */
13
	protected $defer = false;
14
15
	/**
16
	 * Bootstrap the application events.
17
	 *
18
	 * @return void
19
	 */
20
	public function boot()
21
	{
22
		$this->loadViewsFrom(base_path('resources/views/cornford/googlitics'), 'googlitics');
23
24
		$this->publishes(
25
			[
26
				__DIR__ . '/../../config/config.php' => config_path('googlitics.php'),
27
				__DIR__ . '/../../views' => base_path('resources/views/cornford/googlitics')
28
			],
29
			'googlitics'
30
		);
31
	}
32
33
	/**
34
	 * Register the service provider.
35
	 *
36
	 * @return void
37
	 */
38
	public function register()
39
	{
40
		$configPath = __DIR__ . '/../../config/config.php';
41
		$this->mergeConfigFrom($configPath, 'googlitics');
42
43
        $this->app->singleton('analytics', function($app)
44
		{
45
			return new Analytics(
46
				$this->app->make('Illuminate\Foundation\Application'),
47
				$this->app->view,
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...
48
				$app['config']->get('googlitics')
49
			);
50
		});
51
	}
52
53
	/**
54
	 * Get the services provided by the provider.
55
	 *
56
	 * @return array
57
	 */
58
	public function provides()
59
	{
60
		return array('analytics');
61
	}
62
63
}
64