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

PaymentsServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 72%

Importance

Changes 3
Bugs 2 Features 1
Metric Value
wmc 7
eloc 15
c 3
b 2
f 1
dl 0
loc 58
ccs 18
cts 25
cp 0.72
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A registerPurchaseSessions() 0 4 1
A provides() 0 3 1
A setPurchaseModel() 0 3 1
A setPurchaseSessionsModel() 0 3 1
A register() 0 5 1
A registerPurchases() 0 4 1
A registerGatewaysManager() 0 4 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