ErrorMessageTranslator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTranslatedErrorMessageByCode() 0 5 1
A getSdkTranslation() 0 4 1
A __construct() 0 3 1
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\Client\Heidelpay\MessageTranslator;
9
10
use SprykerEco\Client\Heidelpay\Sdk\HeidelpayApiAdapterInterface;
11
12
/**
13
 * @method \SprykerEco\Client\Heidelpay\HeidelpayFactory getFactory()
14
 */
15
class ErrorMessageTranslator implements ErrorMessageTranslatorInterface
16
{
17
    /**
18
     * @var \SprykerEco\Client\Heidelpay\Sdk\HeidelpayApiAdapterInterface
19
     */
20
    protected $heidelpayApiAdapter;
21
22
    /**
23
     * @param \SprykerEco\Client\Heidelpay\Sdk\HeidelpayApiAdapterInterface $heidelpayApiAdapter
24
     */
25
    public function __construct(HeidelpayApiAdapterInterface $heidelpayApiAdapter)
26
    {
27
        $this->heidelpayApiAdapter = $heidelpayApiAdapter;
28
    }
29
30
    /**
31
     * @param string $errorCode
32
     * @param string $locale
33
     *
34
     * @return string
35
     */
36
    public function getTranslatedErrorMessageByCode($errorCode, $locale): string
37
    {
38
        $translatedMessage = $this->getSdkTranslation($errorCode, $locale);
39
40
        return $translatedMessage;
41
    }
42
43
    /**
44
     * @param string $errorCode
45
     * @param string $locale
46
     *
47
     * @return string
48
     */
49
    protected function getSdkTranslation($errorCode, $locale): string
50
    {
51
        return $this->heidelpayApiAdapter
52
            ->getTranslatedMessageByCode($errorCode, $locale);
53
    }
54
}
55