ZendeskServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 22
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 16 2
1
<?php
2
3
namespace NotificationChannels\Zendesk;
4
5
use Zendesk\API\HttpClient;
6
use Illuminate\Support\ServiceProvider;
7
use NotificationChannels\Zendesk\Exceptions\InvalidConfiguration;
8
9
class ZendeskServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Register the application services.
13
     */
14
    public function register()
15
    {
16
        $this->app->when(ZendeskChannel::class)
17
            ->needs(HttpClient::class)
18
            ->give(function () {
19
                $config = config('services.zendesk');
20
                if (! isset($config['subdomin'], $config['username'], $config['token'])) {
21
                    throw InvalidConfiguration::configurationNotSet();
22
                }
23
24
                $client = new HttpClient($config['subdomin']);
25
                $client->setAuth('basic', ['username' => $config['username'], 'token' => $config['token']]);
26
27
                return $client;
28
            });
29
    }
30
}
31