GeldServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 2
b 0
f 0
dl 0
loc 40
ccs 17
cts 17
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 15 2
A register() 0 13 1
1
<?php
2
3
namespace VictorAvelar\Geld;
4
5
use Illuminate\Support\ServiceProvider;
6
use VictorAvelar\Fixer\FixerHttpClient;
7
use VictorAvelar\Fixer\Resources\LatestRatesResource;
8
use VictorAvelar\Geld\Commands\CheckRetentionCommand;
9
use VictorAvelar\Geld\Commands\DataIncineratorCommand;
10
use VictorAvelar\Geld\Commands\UpdateExchangeRatesCommand;
11
12
/**
13
 * Class GeldServiceProvider
14
 *
15
 * @package VictorAvelar\Geld
16
 * @author Victor Avelar <[email protected]>
17
 */
18
class GeldServiceProvider extends ServiceProvider
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 15
    public function boot()
24
    {
25
        // configuration
26 15
        $this->publishes([
27 15
            __DIR__ . '/../config/geld.php' => config_path('geld.php')
28
        ]);
29
30
        // migrations
31 15
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
32
33 15
        if ($this->app->runningInConsole()) {
34 15
            $this->commands([
35 15
                UpdateExchangeRatesCommand::class,
36
                CheckRetentionCommand::class,
37
                DataIncineratorCommand::class,
38
            ]);
39
        }
40 15
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 15
    public function register()
46
    {
47 15
        $this->mergeConfigFrom(
48 15
            __DIR__.'/../config/geld.php',
49 15
            'geld'
50
        );
51
52 10
        $this->app->singleton(FixerHttpClient::class, function () {
53 15
            return new FixerHttpClient(config("geld.access_key"));
54 15
        });
55
56 10
        $this->app->singleton(LatestRatesResource::class, function ($app) {
57 15
            return new LatestRatesResource($app->make(FixerHttpClient::class));
58 15
        });
59 15
    }
60
}
61