Completed
Push — master ( a1a6a3...9324c5 )
by Jean C.
04:28
created

src/Providers/MoipServiceProvider.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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