Completed
Pull Request — master (#1)
by Dmitry
02:45
created

AbstractMerchant   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 50
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getCredentials() 0 4 1
createGateway() 0 1 ?
1
<?php
2
3
namespace hiqdev\php\merchant\merchants;
4
5
use hiqdev\php\merchant\credentials\CredentialsInterface;
6
use hiqdev\php\merchant\factories\GatewayFactoryInterface;
7
use Money\MoneyFormatter;
8
use Money\MoneyParser;
9
use Omnipay\Common\GatewayInterface;
10
11
abstract class AbstractMerchant implements MerchantInterface
12
{
13
    /**
14
     * @var GatewayInterface
15
     */
16
    protected $gateway;
17
    /**
18
     * @var CredentialsInterface
19
     */
20
    protected $credentials;
21
    /**
22
     * @var GatewayFactoryInterface
23
     */
24
    protected $gatewayFactory;
25
    /**
26
     * @var MoneyFormatter
27
     */
28
    protected $moneyFormatter;
29
    /**
30
     * @var MoneyParser
31
     */
32
    protected $moneyParser;
33
34
    public function __construct(
35
        CredentialsInterface $credentials,
36
        GatewayFactoryInterface $gatewayFactory,
37
        MoneyFormatter $moneyFormatter,
38
        MoneyParser $moneyParser
39
    ) {
40
        $this->credentials = $credentials;
41
        $this->gatewayFactory = $gatewayFactory;
42
        $this->moneyFormatter = $moneyFormatter;
43
        $this->moneyParser = $moneyParser;
44
        $this->gateway = $this->createGateway();
45
    }
46
47
    /**
48
     * @return CredentialsInterface
49
     */
50
    public function getCredentials(): CredentialsInterface
51
    {
52
        return $this->credentials;
53
    }
54
55
    /**
56
     * @return GatewayInterface
57
     */
58
    abstract protected function createGateway();
59
60
}
61