Passed
Pull Request — master (#22)
by Manuel
03:42
created

Translation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 59
dl 0
loc 78
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllByLanguage() 0 5 2
A get() 0 6 3
1
<?php
2
3
namespace Sprain\SwissQrBill\PaymentPart\Translation;
4
5
class Translation
6
{
7
    private const TRANSLATIONS = [
8
        'de' => [
9
            'paymentPart' => 'Zahlteil',
10
            'creditor' => 'Konto / Zahlbar an',
11
            'reference' => 'Referenz',
12
            'additionalInformation' => 'Zusätzliche Informationen',
13
            'currency' => 'Währung',
14
            'amount' => 'Betrag',
15
            'receipt' => 'Empfangsschein',
16
            'acceptancePoint' => 'Annahmestelle',
17
            'separate' => 'Vor der Einzahlung abzutrennen',
18
            'payableBy' => 'Zahlbar durch',
19
            'payableByName' => 'Zahlbar durch (Name/Adresse)',
20
            'inFavorOf' => 'Zugunsten'
21
        ],
22
23
        'fr' => [
24
            'paymentPart' => 'Section paiement',
25
            'creditor' => 'Compte / Payable à',
26
            'reference' => 'Référence',
27
            'additionalInformation' => 'Informations supplémentaires',
28
            'currency' => 'Monnaie',
29
            'amount' => 'Montant',
30
            'receipt' => 'Récépissé',
31
            'acceptancePoint' => 'Point de dépôt',
32
            'separate' => 'A détacher avant le versement',
33
            'payableBy' => 'Payable par',
34
            'payableByName' => 'Payable par (nom/adresse)',
35
            'inFavorOf' => 'En faveur de'
36
        ],
37
38
        'it' => [
39
            'paymentPart' => 'Sezione pagamento',
40
            'creditor' => 'Conto / Pagabile a',
41
            'reference' => 'Riferimento',
42
            'additionalInformation' => 'Informazioni supplementari',
43
            'currency' => 'Valuta',
44
            'amount' => 'Importo',
45
            'receipt' => 'Ricevuta',
46
            'acceptancePoint' => 'Punto di accettazione',
47
            'separate' => 'Da staccare prima del versamento',
48
            'payableBy' => 'Pagabile da',
49
            'payableByName' => 'Pagabile da (nome/indirizzo)',
50
            'inFavorOf' => 'A favore di'
51
        ],
52
53
        'en' => [
54
            'paymentPart' => 'Payment part',
55
            'creditor' => 'Account / Payable to',
56
            'reference' => 'Reference',
57
            'additionalInformation' => 'Additional information',
58
            'currency' => 'Currency',
59
            'amount' => 'Amount',
60
            'receipt' => 'Receipt',
61
            'acceptancePoint' => 'Acceptance point',
62
            'separate' => 'Separate before paying in',
63
            'payableBy' => 'Payable by',
64
            'payableByName' => 'Payable by (name/address)',
65
            'inFavorOf' => 'In favour of'
66
        ]
67
    ];
68
69
    public static function getAllByLanguage($language) :?array
70
    {
71
        if (array_key_exists($language, self::TRANSLATIONS)) {
72
73
            return self::TRANSLATIONS[$language];
74
        }
75
    }
76
77
    public static function get(string $key, string $language) : ?string
78
    {
79
        if ($translations = self::getAllByLanguage($language)) {
80
            if (array_key_exists($key, $translations)) {
81
82
                return $translations[$key];
83
            }
84
        }
85
    }
86
}