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

AbstractMerchant   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 49
ccs 9
cts 9
cp 1
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
 * 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