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

MoipServiceProvider::isLumen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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 Jean C. Garcia
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