Completed
Push — master ( 22a8c1...54d362 )
by Jean C.
01:55
created

MoipServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 4 1
A provides() 0 4 1
A handleConfigs() 0 12 2
A isLumen() 0 4 1
1
<?php
2
3
namespace Artesaos\Moip\Providers;
4
5
use Artesaos\Moip\Moip;
6
use Illuminate\Support\ServiceProvider;
7
8
/**
9
 * Class MoipServiceProvider.
10
 *
11
 * @package Artesaos\Moip\Providers
12
 */
13
class MoipServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Indicates if loading of the provider is deferred.
17
     *
18
     * @var bool
19
     */
20
    protected $defer = true;
21
22
    /**
23
     * Bootstrap the application events.
24
     */
25
    public function boot()
26
    {
27
        $this->handleConfigs();
28
    }
29
30
    /**
31
     * Register the service provider.
32
     */
33
    public function register()
34
    {
35
        $this->app->singleton('moip', Moip::class);
36
    }
37
38
    /**
39
     * Get the services provided by the provider.
40
     *
41
     * @return array
42
     */
43
    public function provides()
44
    {
45
        return ['moip'];
46
    }
47
48
    /**
49
     * Publishes and Merge configs.
50
     */
51
    public function handleConfigs()
52
    {
53
        $config_file = __DIR__.'/../../config/moip.php';
54
55
        if ($this->isLumen()) {
56
            $this->app->configure('moip');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean registerConfiguredProviders()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
57
        } else {
58
            $this->publishes([$config_file => config_path('moip.php')]);
59
        }
60
61
        $this->mergeConfigFrom($config_file, 'moip');
62
    }
63
64
    /**
65
     * Checks if the application is Lumen.
66
     *
67
     * @return bool
68
     */
69
    private function isLumen()
70
    {
71
        return true === str_contains($this->app->version(), 'Lumen');
72
    }
73
}
74