Passed
Push — master ( f03f32...2d9324 )
by Gabriel
10:58
created

PaymentsServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
3
namespace ByTIC\Payments;
4
5
use ByTIC\Payments\Gateways\Manager;
6
use ByTIC\Payments\Utility\PaymentsModels;
7
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
8
use Nip\Container\ServiceProviders\Providers\BootableServiceProviderInterface;
9
10
/**
11
 * Class PaymentsServiceProvider
12
 * @package ByTIC\Payments
13
 */
14
class PaymentsServiceProvider extends AbstractSignatureServiceProvider implements BootableServiceProviderInterface
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public function register()
20
    {
21 1
        $this->registerPurchases();
22
        $this->registerGatewaysManager();
23 1
        $this->registerPurchaseSessions();
24 1
    }
25 1
26 1
    /**
27
     * @inheritdoc
28
     */
29
    public function provides()
30 1
    {
31 1
        return ['purchases', 'purchase-sessions', 'payments.gateways'];
32 1
    }
33 1
34
    public function boot()
35
    {
36
        $this->getContainer()->get('migrations.migrator')->path(dirname(__DIR__) . '/migrations/');
37 1
    }
38
39 1
    protected function registerPurchases()
40 1
    {
41
        $this->getContainer()->share('purchases', function () {
42
            return PaymentsModels::purchases();
43
        });
44 1
    }
45
46 1
    protected function registerPurchaseSessions()
47 1
    {
48
        $this->getContainer()->share('purchase-sessions', function () {
49
            return PaymentsModels::sessions();
50
        });
51
    }
52 1
53
    protected function registerGatewaysManager()
54 1
    {
55 1
        $this->getContainer()->singleton('payments.gateways', function () {
0 ignored issues
show
Bug introduced by
The method singleton() does not exist on Nip\Container\ContainerInterface. It seems like you code against a sub-type of Nip\Container\ContainerInterface such as Nip\Container\Container or Nip\Container\Container. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        $this->getContainer()->/** @scrutinizer ignore-call */ singleton('payments.gateways', function () {
Loading history...
56
            return new Manager();
57
        });
58
    }
59
}
60