Passed
Pull Request — master (#4)
by Aleksey
09:30 queued 04:56
created

CrefoPayPaymentMethodMapper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInternalToExternalPaymentMethodNamesMapping() 0 3 1
A __construct() 0 3 1
A mapInternalToExternalPaymentMethodName() 0 9 2
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\CrefoPay\Business\Mapper\PaymentMethod;
9
10
use SprykerEco\Zed\CrefoPay\CrefoPayConfig;
11
12
class CrefoPayPaymentMethodMapper implements CrefoPayPaymentMethodMapperInterface
13
{
14
    /**
15
     * @var \SprykerEco\Zed\CrefoPay\CrefoPayConfig
16
     */
17
    protected $config;
18
19
    /**
20
     * @param \SprykerEco\Zed\CrefoPay\CrefoPayConfig $config
21
     */
22
    public function __construct(CrefoPayConfig $config)
23
    {
24
        $this->config = $config;
25
    }
26
27
    /**
28
     * @param string $internalPaymentMethodName
29
     *
30
     * @return string|null
31
     */
32
    public function mapInternalToExternalPaymentMethodName(string $internalPaymentMethodName): ?string
33
    {
34
        $paymentMethodNames = $this->getInternalToExternalPaymentMethodNamesMapping();
35
36
        if (!isset($paymentMethodNames[$internalPaymentMethodName])) {
37
            return null;
38
        }
39
40
        return $paymentMethodNames[$internalPaymentMethodName];
41
    }
42
43
    /**
44
     * @return string[]
45
     */
46
    protected function getInternalToExternalPaymentMethodNamesMapping(): array
47
    {
48
        return $this->config->getInternalToExternalPaymentMethodNamesMapping();
49
    }
50
}
51