Completed
Push — master ( e1812c...00ede7 )
by Mike
04:28
created

GeocoderService::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php namespace Geocoder\Laravel\Providers;
2
3
/**
4
 * This file is part of the Geocoder Laravel package.
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author Mike Bronner <[email protected]>
9
 * @license    MIT License
10
 */
11
12
use Geocoder\Laravel\Facades\Geocoder;
13
use Geocoder\Laravel\ProviderAndDumperAggregator;
14
use Geocoder\Provider\Chain\Chain;
15
use Illuminate\Foundation\AliasLoader;
16
use Illuminate\Support\Collection;
17
use Illuminate\Support\ServiceProvider;
18
use ReflectionClass;
19
20
class GeocoderService extends ServiceProvider
21
{
22
    protected $defer = false;
23
24 21
    public function boot()
25
    {
26 21
        $configPath = __DIR__ . '/../../config/geocoder.php';
27 21
        $this->publishes([$configPath => config_path('geocoder.php')], 'config');
28 21
        $this->mergeConfigFrom($configPath, 'geocoder');
29 21
        $this->app->singleton('geocoder', function () {
30 19
            return (new ProviderAndDumperAggregator)->registerProvidersFromConfig(collect(config('geocoder.providers')));
31 21
        });
32 21
    }
33
34 21
    public function register()
35
    {
36 21
        $this->app->alias('Geocoder', Geocoder::class);
37 21
    }
38
39
    public function provides() : array
40
    {
41
        return ['geocoder'];
42
    }
43
}
44