ErrorMessageTranslator::getSdkTranslation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 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\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