Completed
Pull Request — master (#1)
by Dmitry
11:43 queued 10:09
created

AbstractMerchant::getCredentials()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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