Completed
Pull Request — master (#85)
by
unknown
09:07
created

Localization   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 103
c 0
b 0
f 0
wmc 10
lcom 2
cbo 0
rs 10
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\Pass;
13
14
/**
15
 * Localization
16
 */
17
class Localization implements LocalizationInterface
18
{
19
    /**
20
     * Language of the localization
21
     */
22
    protected string $language;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
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
    public function __construct($language)
39
    {
40
        $this->setLanguage($language);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function setLanguage($language): void
47
    {
48
        $this->language = $language;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getLanguage()
55
    {
56
        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
    public function addStrings(array $strings)
73
    {
74
        $this->strings = array_merge($this->strings, $strings);
75
76
        return $this;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getStrings()
83
    {
84
        return $this->strings;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function getStringsFileOutput()
91
    {
92
        $output = '';
93
        foreach ($this->strings as $token => $value) {
94
            $output .= '"' . addslashes($token) . '" = "' . addslashes($value) . '";' . PHP_EOL;
95
        }
96
97
        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
    public function getImages()
114
    {
115
        return $this->images;
116
    }
117
}
118