Passed
Push — google-wallet-support ( 15e26d...cd8842 )
by Razvan
04:15
created

Localization::getStrings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Passbook package.
5
 *
6
 * (c) Eymen Gunay <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Passbook\Apple;
13
14
/**
15
 * Localization
16
 */
17
class Localization implements LocalizationInterface
18
{
19
    /**
20
     * Language of the localization
21
     */
22
    protected string $language;
23
24
    /**
25
     * Localized images
26
     *
27
     * @var ImageInterface[]
28
     */
29
    protected array $images = [];
30
31
    /**
32
     * Localized texts (token=>value)
33
     *
34
     * @var string[]
35
     */
36
    protected array $strings = [];
37
38 1
    public function __construct($language)
39
    {
40 1
        $this->setLanguage($language);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function setLanguage($language): void
47
    {
48 1
        $this->language = $language;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function getLanguage()
55
    {
56 1
        return $this->language;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function addString($token, $value)
63
    {
64
        $this->strings[$token] = $value;
65
66
        return $this;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72 1
    public function addStrings(array $strings)
73
    {
74 1
        $this->strings = array_merge($this->strings, $strings);
75
76 1
        return $this;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getStrings()
83
    {
84
        return $this->strings;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90 1
    public function getStringsFileOutput()
91
    {
92 1
        $output = '';
93 1
        foreach ($this->strings as $token => $value) {
94 1
            $output .= '"' . addslashes($token) . '" = "' . addslashes($value) . '";' . PHP_EOL;
95
        }
96
97 1
        return $output;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function addImage(Image $image)
104
    {
105
        $this->images[] = $image;
106
107
        return $this;
108
    }
109
110
    /**
111
     * {@inheritdoc}
112
     */
113 1
    public function getImages()
114
    {
115 1
        return $this->images;
116
    }
117
}
118