LocationServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 6
c 6
b 0
f 0
dl 0
loc 13
rs 10
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Stevebauman\Location;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Support\ServiceProvider;
7
8
class LocationServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Run boot operations.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        if ($this->isLumen()) {
18
            return;
19
        }
20
21
        $config = __DIR__.'/../config/config.php';
22
23
        if ($this->app->runningInConsole()) {
24
            $this->publishes([$config => config_path('location.php')]);
25
        }
26
27
        $this->mergeConfigFrom($config, 'location');
28
    }
29
30
    /**
31
     * Register the location binding.
32
     *
33
     * @return void
34
     */
35
    public function register()
36
    {
37
        $this->app->singleton('location', function ($app) {
38
            return new Location($app['config']);
39
        });
40
    }
41
42
    /**
43
     * Get the services provided by the provider.
44
     *
45
     * @return array
46
     */
47
    public function provides()
48
    {
49
        return ['location'];
50
    }
51
52
    /**
53
     * Determine if the current application is Lumen.
54
     *
55
     * @return bool
56
     */
57
    protected function isLumen()
58
    {
59
        return Str::contains($this->app->version(), 'Lumen');
60
    }
61
}
62