Passed
Push — master ( 209f8f...1618ee )
by Gabriel
06:05
created

PaymentsServiceProvider::setPurchaseModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace ByTIC\Payments;
4
5
use ByTIC\Payments\Gateways\Manager;
6
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
7
use Nip\Records\Locator\ModelLocator;
8
9
/**
10
 * Class PaymentsServiceProvider
11
 * @package ByTIC\Payments
12
 */
13
class PaymentsServiceProvider extends AbstractSignatureServiceProvider
14
{
15
    protected static $purchaseModel = 'purchases';
16
    protected static $purchaseSessionsModel = 'purchase-sessions';
17
18
    /**
19
     * @inheritdoc
20
     */
21 1
    public function register()
22
    {
23 1
        $this->registerPurchases();
24 1
        $this->registerGatewaysManager();
25 1
        $this->registerPurchaseSessions();
26 1
    }
27
28
    protected function registerPurchases()
29
    {
30 1
        $this->getContainer()->share('purchases', function () {
31 1
            return ModelLocator::get($this::$purchaseModel);
32 1
        });
33 1
    }
34
35
    protected function registerPurchaseSessions()
36
    {
37 1
        $this->getContainer()->share('purchase-sessions', function () {
38
            return ModelLocator::get($this::$purchaseSessionsModel);
39 1
        });
40 1
    }
41
42
    protected function registerGatewaysManager()
43
    {
44 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

44
        $this->getContainer()->/** @scrutinizer ignore-call */ singleton('payments.gateways', function () {
Loading history...
45
            return new Manager();
46 1
        });
47 1
    }
48
49
    /**
50
     * @param string $purchaseModel
51
     */
52 1
    public static function setPurchaseModel(string $purchaseModel)
53
    {
54 1
        self::$purchaseModel = $purchaseModel;
55 1
    }
56
57
    /**
58
     * @param string $purchaseSessionsModel
59
     */
60
    public static function setPurchaseSessionsModel(string $purchaseSessionsModel)
61
    {
62
        self::$purchaseSessionsModel = $purchaseSessionsModel;
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function provides()
69
    {
70
        return ['purchases', 'purchase-sessions','payments.gateways'];
71
    }
72
}
73