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

src/Providers/MoipServiceProvider.php (1 issue)

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