Completed
Push — master ( 6e1d34...22a8c1 )
by Jean C.
02:15
created

MoipServiceProvider::getHomologated()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace Artesaos\Moip\Providers;
4
5
use Artesaos\Moip\Moip;
6
use Moip\Moip as Api;
7
use Moip\MoipBasicAuth;
8
use Illuminate\Support\ServiceProvider;
9
10
class MoipServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Indicates if loading of the provider is deferred.
14
     *
15
     * @var bool
16
     */
17
    protected $defer = true;
18
19
    /**
20
     * Bootstrap the application events.
21
     */
22
    public function boot()
23
    {
24
        $this->handleConfigs();
25
    }
26
27
    /**
28
     * Register the service provider.
29
     */
30
    public function register()
31
    {
32
        $this->app->singleton('moip', function(){
33
            return new Moip(new Api(new MoipBasicAuth(config('moip.credentials.token'), config('moip.credentials.key')), $this->getHomologated()));
0 ignored issues
show
Unused Code introduced by Jean C. Garcia
The call to Moip::__construct() has too many arguments starting with new \Moip\Moip(new \Moip...this->getHomologated()).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
        });
35
    }
36
37
    /**
38
     * Get the services provided by the provider.
39
     *
40
     * @return array
41
     */
42
    public function provides()
43
    {
44
        return ['moip'];
45
    }
46
47
    /**
48
     * Publishes and Merge configs.
49
     */
50
    public function handleConfigs()
51
    {
52
        $this->publishes([__DIR__.'/../../config/moip.php' => config_path('/artesaos/moip.php')], 'config');
53
        $this->mergeConfigFrom(__DIR__.'/../../config/moip.php', config_path('/artesaos/moip.php', 'config'));
54
    }
55
56
    /**
57
     * Get endpoint of request.
58
     *
59
     * @return \Moip\Moip::ENDPOINT_PRODUCTION|\Moip\Moip::ENDPOINT_SANDBOX
60
     */
61
    private function getHomologated()
62
    {
63
        return config('moip.homologated') === true ? Api::ENDPOINT_PRODUCTION : Api::ENDPOINT_SANDBOX;
64
    }
65
}
66