FreshdeskServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 4 1
A boot() 0 11 4
A register() 0 8 1
1
<?php
2
3
namespace Mpclarkson\Laravel\Freshdesk;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Foundation\Application as LaravelApplication;
7
use Laravel\Lumen\Application as LumenApplication;
8
9
class FreshdeskServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $source = dirname(__DIR__).'/src/config/freshdesk.php';
19
20
        if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
21
            $this->publishes([$source => config_path('freshdesk.php')]);
22
        } elseif ($this->app instanceof LumenApplication) {
23
            $this->app->configure('freshdesk');
24
        }
25
        $this->mergeConfigFrom($source, 'freshdesk');
26
    }
27
28
    /**
29
     * Register the application services.
30
     *
31
     * @return void
32
     */
33
    public function register()
34
    {
35
        $this->app->singleton('freshdesk', function ($app) {
36
            $config = $app->make('config')->get('freshdesk');
37
            return new Api($config['api_key'], $config['domain']);
38
        });
39
        $this->app->alias('freshdesk', Api::class);
40
    }
41
42
    /**
43
     * Get the services provided by the provider.
44
     *
45
     * @return array
46
     */
47
    public function provides()
48
    {
49
        return ['freshdesk', Api::class];
50
    }
51
}
52