Completed
Push — master ( 259fd8...a43b07 )
by Andrii
03:33
created

AbstractMerchant::getCredentials()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Generalization over Omnipay and Payum
4
 *
5
 * @link      https://github.com/hiqdev/php-merchant
6
 * @package   php-merchant
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\merchant\merchants;
12
13
use hiqdev\php\merchant\credentials\CredentialsInterface;
14
use hiqdev\php\merchant\factories\GatewayFactoryInterface;
15
use Money\MoneyFormatter;
16
use Money\MoneyParser;
17
use Omnipay\Common\GatewayInterface;
18
19
abstract class AbstractMerchant implements MerchantInterface
20
{
21
    /**
22
     * @var GatewayInterface
23
     */
24
    protected $gateway;
25
    /**
26
     * @var CredentialsInterface
27
     */
28
    protected $credentials;
29
    /**
30
     * @var GatewayFactoryInterface
31
     */
32
    protected $gatewayFactory;
33
    /**
34
     * @var MoneyFormatter
35
     */
36
    protected $moneyFormatter;
37
    /**
38
     * @var MoneyParser
39
     */
40
    protected $moneyParser;
41
42 30
    public function __construct(
43
        CredentialsInterface $credentials,
44
        GatewayFactoryInterface $gatewayFactory,
45
        MoneyFormatter $moneyFormatter,
46
        MoneyParser $moneyParser
47
    ) {
48 30
        $this->credentials = $credentials;
49 30
        $this->gatewayFactory = $gatewayFactory;
50 30
        $this->moneyFormatter = $moneyFormatter;
51 30
        $this->moneyParser = $moneyParser;
52 30
        $this->gateway = $this->createGateway();
53 30
    }
54
55
    /**
56
     * @return CredentialsInterface
57
     */
58 5
    public function getCredentials(): CredentialsInterface
59
    {
60 5
        return $this->credentials;
61
    }
62
63
    /**
64
     * @return GatewayInterface
65
     */
66
    abstract protected function createGateway();
67
}
68