PayerPagSeguroServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 11 1
A register() 0 16 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: igor
5
 * Date: 10/06/18
6
 * Time: 10:04
7
 */
8
9
namespace AdminWeb\PayerPagSeguro;
10
11
12
use AdminWeb\Payer\EnvInterface;
13
use AdminWeb\Payer\SubscriptionInterface;
14
use AdminWeb\PayerPagSeguro\Env\Production;
15
use AdminWeb\PayerPagSeguro\Env\SandBox;
16
use AdminWeb\PayerPagSeguro\States\WaitingPayment;
17
use Illuminate\Support\ServiceProvider;
18
19
class PayerPagSeguroServiceProvider extends ServiceProvider
20
{
21
    public function boot()
22
    {
23
        $this->publishes([
24
            __DIR__ . '/../config/payerpagseguro.php' => config_path('payerpagseguro.php'),
25
        ]);
26
27
        $this->loadRoutesFrom(__DIR__.'/../routes/routes.php');
28
29
        //$this->loadMigrationsFrom(__DIR__ . '/../migrations');
30
31
        $this->loadViewsFrom(__DIR__ . '/../views', 'payer');
32
33
    }
34
35
    public function register()
36
    {
37
        $this->app->bind(EnvInterface::class, function(){
38
            $env = $this->app['config']['app']['env'];
39
            if($env == strtolower('production')){
40
                return new Production(env('PAGSEGURO_EMAIL'), env('PAGSEGURO_TOKEN'));
41
            }
42
            return new SandBox(env('PAGSEGURO_EMAIL_SANDBOX'), env('PAGSEGURO_TOKEN_SANBOX'));
43
        });
44
45
        $this->app->bind('InitialState',function(){
46
            return new WaitingPayment();
47
        });
48
49
        $this->app->bind(SubscriptionInterface::class,function(){
50
            return new Subscription();
51
        });
52
    }
53
}