Completed
Push — master ( 3d9086...304184 )
by Bradley
02:01
created

src/Cornford/Googlmapper/MapperServiceProvider.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace Cornford\Googlmapper;
2
3
use Illuminate\Support\ServiceProvider;
4
use Illuminate\Support\Facades\Config;
5
6
class MapperServiceProvider 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/googlmapper'), 'googlmapper');
23
24
		$this->publishes(
25
			[
26
				__DIR__ . '/../../config/config.php' => config_path('googlmapper.php'),
27
				__DIR__ . '/../../views' => base_path('resources/views/cornford/googlmapper')
28
			],
29
			'googlmapper'
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, 'googlmapper');
42
43
        $this->app->singleton(
44
            'mapper',
45
            function($app)
46
            {
47
                return new Mapper($this->app->view, $app['config']->get('googlmapper'));
0 ignored issues
show
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
            }
49
        );
50
	}
51
52
	/**
53
	 * Get the services provided by the provider.
54
	 *
55
	 * @return array
56
	 */
57
	public function provides()
58
	{
59
		return array('mapper');
60
	}
61
62
}
63