Passed
Pull Request — master (#4)
by Aleksey
08:38 queued 04:31
created

CrefoPayOmsStatusMapper   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 61
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A mapNotificationOrderStatusToOmsStatus() 0 9 2
A getNotificationTransactionToOmsStatusMapping() 0 3 1
A getNotificationOrderToOmsStatusMapping() 0 3 1
A __construct() 0 3 1
A mapNotificationTransactionStatusToOmsStatus() 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\OmsStatus;
9
10
use SprykerEco\Zed\CrefoPay\CrefoPayConfig;
11
12
class CrefoPayOmsStatusMapper implements CrefoPayOmsStatusMapperInterface
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 $apiStatus
29
     *
30
     * @return string|null
31
     */
32
    public function mapNotificationTransactionStatusToOmsStatus(string $apiStatus): ?string
33
    {
34
        $statuses = $this->getNotificationTransactionToOmsStatusMapping();
35
36
        if (!isset($statuses[$apiStatus])) {
37
            return null;
38
        }
39
40
        return $statuses[$apiStatus];
41
    }
42
43
    /**
44
     * @param string $apiStatus
45
     *
46
     * @return string|null
47
     */
48
    public function mapNotificationOrderStatusToOmsStatus(string $apiStatus): ?string
49
    {
50
        $statuses = $this->getNotificationOrderToOmsStatusMapping();
51
52
        if (!isset($statuses[$apiStatus])) {
53
            return null;
54
        }
55
56
        return $statuses[$apiStatus];
57
    }
58
59
    /**
60
     * @return string[]
61
     */
62
    protected function getNotificationTransactionToOmsStatusMapping(): array
63
    {
64
        return $this->config->getNotificationTransactionToOmsStatusMapping();
65
    }
66
67
    /**
68
     * @return string[]
69
     */
70
    protected function getNotificationOrderToOmsStatusMapping(): array
71
    {
72
        return $this->config->getNotificationOrderToOmsStatusMapping();
73
    }
74
}
75