HubPlannerProvider::boot()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
1
<?php
2
namespace AlfredNutileInc\HPClient;
3
4
use Illuminate\Support\ServiceProvider;
5
use GuzzleHttp\Client;
6
7
class HubPlannerProvider extends ServiceProvider
8
{
9
10
    public function boot()
11
    {
12
13
        $this->publishes([
14
            __DIR__ . '/../hpconfig.php' => config_path('hpconfig.php'),
15
        ]);
16
17
        $this->mergeConfigFrom(
18
            __DIR__ . '/../hpconfig.php',
19
            'hpconfig'
20
        );
21
22
        $this->app->singleton(
23
            HubPlannerClient::class,
24
            function () {
25
                $client = new \GuzzleHttp\Client([
26
                    'base_uri' => 'https://api.hubplanner.com/',
27
                    'headers' => [
28
                        'Authorization' => config('hpconfig.key'),
29
                        'Accept' => 'application/json',
30
                        'Content-Type' => 'application/json'
31
                    ]
32
                ]);
33
                return new HubPlannerClient($client);
34
            }
35
        );
36
    }
37
}
38