Translation::getAllByLanguage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace Sprain\SwissQrBill\PaymentPart\Translation;
4
5
final 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
            'doNotUseForPayment' => 'NICHT ZUR ZAHLUNG VERWENDEN',
22
        ],
23
24
        'fr' => [
25
            'paymentPart' => 'Section paiement',
26
            'creditor' => 'Compte / Payable à',
27
            'reference' => 'Référence',
28
            'additionalInformation' => 'Informations supplémentaires',
29
            'currency' => 'Monnaie',
30
            'amount' => 'Montant',
31
            'receipt' => 'Récépissé',
32
            'acceptancePoint' => 'Point de dépôt',
33
            'separate' => 'A détacher avant le versement',
34
            'payableBy' => 'Payable par',
35
            'payableByName' => 'Payable par (nom/adresse)',
36
            'inFavorOf' => 'En faveur de',
37
            'doNotUseForPayment' => 'NE PAS UTILISER POUR LE PAIEMENT',
38
        ],
39
40
        'it' => [
41
            'paymentPart' => 'Sezione pagamento',
42
            'creditor' => 'Conto / Pagabile a',
43
            'reference' => 'Riferimento',
44
            'additionalInformation' => 'Informazioni supplementari',
45
            'currency' => 'Valuta',
46
            'amount' => 'Importo',
47
            'receipt' => 'Ricevuta',
48
            'acceptancePoint' => 'Punto di accettazione',
49
            'separate' => 'Da staccare prima del versamento',
50
            'payableBy' => 'Pagabile da',
51
            'payableByName' => 'Pagabile da (nome/indirizzo)',
52
            'inFavorOf' => 'A favore di',
53
            'doNotUseForPayment' => 'NON UTILIZZARE PER IL PAGAMENTO',
54
        ],
55
56
        'en' => [
57
            'paymentPart' => 'Payment part',
58
            'creditor' => 'Account / Payable to',
59
            'reference' => 'Reference',
60
            'additionalInformation' => 'Additional information',
61
            'currency' => 'Currency',
62
            'amount' => 'Amount',
63
            'receipt' => 'Receipt',
64
            'acceptancePoint' => 'Acceptance point',
65
            'separate' => 'Separate before paying in',
66
            'payableBy' => 'Payable by',
67
            'payableByName' => 'Payable by (name/address)',
68
            'inFavorOf' => 'In favour of',
69
            'doNotUseForPayment' => 'DO NOT USE FOR PAYMENT'
70
        ]
71
    ];
72
73
    public static function getAllByLanguage($language): ?array
74
    {
75
        return self::TRANSLATIONS[$language] ?? null;
76
    }
77
78
    public static function get(string $key, string $language): ?string
79
    {
80
        $translations = self::getAllByLanguage($language);
81
        if (! is_array($translations) || ! array_key_exists($key, $translations)) {
82
            return null;
83
        }
84
85
        return $translations[$key];
86
    }
87
}
88