SalesforceServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 22 1
A boot() 0 6 1
1
<?php
2
3
namespace Surge\LaravelSalesforce;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Support\ServiceProvider;
7
8
class SalesforceServiceProvider extends ServiceProvider
9
{
10
    public function register()
11
    {
12
        $this->app->singleton('salesforce', function () {
13
            $authClient = new Client([
14
                'headers' => [
15
                    'Accept' => 'application/json',
16
                ],
17
            ]);
18
19
            $auth = new SalesforceAuth($authClient);
20
21
            $client = new Client([
22
                'headers' => [
23
                    'Accept'        => 'application/json',
24
                    'Authorization' => 'Bearer '.$auth->accessToken,
25
                    'X-PrettyPrint' => '1',
26
                ],
27
            ]);
28
29
            return new Salesforce($client, $auth->url, $auth->instanceUrl);
30
        });
31
    }
32
33
    /**
34
     * Bootstrap the application services.
35
     *
36
     * @return void
37
     */
38
    public function boot()
39
    {
40
        $this->publishes([
41
            __DIR__.'/../config/laravel-salesforce.php' => config_path('laravel-salesforce.php'),
42
        ], 'config');
43
    }
44
}
45