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 | use Moip\Moip as Api; |
||
8 | use Moip\Auth\BasicAuth; |
||
9 | |||
10 | /** |
||
11 | * Class MoipServiceProvider. |
||
12 | * |
||
13 | * @package Artesaos\Moip\Providers |
||
14 | */ |
||
15 | class MoipServiceProvider extends ServiceProvider |
||
16 | { |
||
17 | /** |
||
18 | * Indicates if loading of the provider is deferred. |
||
19 | * |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $defer = true; |
||
23 | |||
24 | /** |
||
25 | * Bootstrap the application events. |
||
26 | */ |
||
27 | public function boot() |
||
28 | { |
||
29 | $this->handleConfigs(); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Register the service provider. |
||
34 | */ |
||
35 | public function register() |
||
36 | { |
||
37 | $this->app->singleton('moip', function(){ |
||
38 | return new Moip(new Api(new BasicAuth($this->app->make('config')->get('moip.credentials.token'), $this->app->make('config')->get('moip.credentials.key')), $this->getHomologated())); |
||
39 | }); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Get the services provided by the provider. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function provides() |
||
48 | { |
||
49 | return ['moip']; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Publishes and Merge configs. |
||
54 | */ |
||
55 | public function handleConfigs() |
||
56 | { |
||
57 | $config_file = __DIR__.'/../../config/moip.php'; |
||
58 | |||
59 | if ($this->isLumen()) { |
||
60 | $this->app->configure('moip'); |
||
0 ignored issues
–
show
|
|||
61 | } else { |
||
62 | $this->publishes([$config_file => config_path('moip.php')]); |
||
63 | } |
||
64 | |||
65 | $this->mergeConfigFrom($config_file, 'moip'); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Checks if the application is Lumen. |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | private function isLumen() |
||
74 | { |
||
75 | return true === str_contains($this->app->version(), 'Lumen'); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Get endpoint of request. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | private function getHomologated() |
||
84 | { |
||
85 | return $this->app->make('config')->get('moip.homologated') === true ? Api::ENDPOINT_PRODUCTION : Api::ENDPOINT_SANDBOX; |
||
86 | } |
||
87 | } |
||
88 |
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.