Message::getLocale()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Happyr\TranslationBundle\Model;
4
5
/**
6
 * @author Tobias Nyholm
7
 */
8
class Message
9
{
10
    /**
11
     * @var int
12
     *
13
     * This is the number of times the message occurs on a specific page
14
     */
15
    private $count;
16
17
    /**
18
     * @var string
19
     *
20
     * The domain the message belongs to
21
     */
22
    private $domain;
23
24
    /**
25
     * @var string
26
     *
27
     * The key/phrase you write in the source code
28
     */
29
    private $id;
30
31
    /**
32
     * @var string
33
     *
34
     * The locale the translations is on
35
     */
36
    private $locale;
37
38
    /**
39
     * @var int
40
     *
41
     * The current state of the translations. See Symfony\Component\Translation\DataCollectorTranslator
42
     *
43
     * MESSAGE_DEFINED = 0;
44
     * MESSAGE_MISSING = 1;
45
     * MESSAGE_EQUALS_FALLBACK = 2;
46
     */
47
    private $state;
48
49
    /**
50
     * @var string
51
     *
52
     * The translated string. This is the preview of the message. Ie no placeholders is visible.
53
     */
54
    private $translation;
55
56
    /**
57
     * @var int
58
     *
59
     * The number which we are feeding a transChoice with
60
     * Used only in Symfony >2.8
61
     */
62
    private $transChoiceNumber;
63
64
    /**
65
     * @var array
66
     *
67
     * The parameters sent to the translations
68
     * Used only in Symfony >2.8
69
     */
70
    private $parameters;
71
72
    /**
73
     * @param array $data
74
     *                    array( count = 1, domain = "navigation", id = "logout", locale = "sv", state = 1, translation = "logout" )
75
     */
76
    public function __construct($data)
77
    {
78
        $this->domain = $data['domain'];
79
        $this->id = $data['id'];
80
        $this->locale = $data['locale'];
81
        $this->state = $data['state'];
82
        $this->translation = $data['translation'];
83
84
        if (isset($data['count'])) {
85
            $this->count = $data['count'];
86
        }
87
88
        if (isset($data['transChoiceNumber'])) {
89
            $this->transChoiceNumber = $data['transChoiceNumber'];
90
        }
91
92
        if (isset($data['parameters'])) {
93
            $this->parameters = $data['parameters'];
94
        }
95
    }
96
97
    /**
98
     * @return int
99
     */
100
    public function getCount()
101
    {
102
        return $this->count;
103
    }
104
105
    /**
106
     * @param int $count
107
     *
108
     * @return $this
109
     */
110
    public function setCount($count)
111
    {
112
        $this->count = $count;
113
114
        return $this;
115
    }
116
117
    /**
118
     * @return string
119
     */
120
    public function getDomain()
121
    {
122
        return $this->domain;
123
    }
124
125
    /**
126
     * @param string $domain
127
     *
128
     * @return $this
129
     */
130
    public function setDomain($domain)
131
    {
132
        $this->domain = $domain;
133
134
        return $this;
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    public function getId()
141
    {
142
        return $this->id;
143
    }
144
145
    /**
146
     * @param string $id
147
     *
148
     * @return $this
149
     */
150
    public function setId($id)
151
    {
152
        $this->id = $id;
153
154
        return $this;
155
    }
156
157
    /**
158
     * @return string
159
     */
160
    public function getLocale()
161
    {
162
        return $this->locale;
163
    }
164
165
    /**
166
     * @param string $locale
167
     *
168
     * @return $this
169
     */
170
    public function setLocale($locale)
171
    {
172
        $this->locale = $locale;
173
174
        return $this;
175
    }
176
177
    /**
178
     * @return int
179
     */
180
    public function getState()
181
    {
182
        return $this->state;
183
    }
184
185
    /**
186
     * @param int $state
187
     *
188
     * @return $this
189
     */
190
    public function setState($state)
191
    {
192
        $this->state = $state;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @return string
199
     */
200
    public function getTranslation()
201
    {
202
        return $this->translation;
203
    }
204
205
    /**
206
     * @param string $translation
207
     *
208
     * @return $this
209
     */
210
    public function setTranslation($translation)
211
    {
212
        $this->translation = $translation;
213
214
        return $this;
215
    }
216
217
    /**
218
     * @return int
219
     */
220
    public function getTransChoiceNumber()
221
    {
222
        return $this->transChoiceNumber;
223
    }
224
225
    /**
226
     * @param int $transChoiceNumber
227
     *
228
     * @return $this
229
     */
230
    public function setTransChoiceNumber($transChoiceNumber)
231
    {
232
        $this->transChoiceNumber = $transChoiceNumber;
233
234
        return $this;
235
    }
236
237
    /**
238
     * @return array
239
     */
240
    public function getParameters()
241
    {
242
        return $this->parameters;
243
    }
244
245
    /**
246
     * @return bool
247
     */
248
    public function hasParameters()
249
    {
250
        return !empty($this->parameters);
251
    }
252
253
    /**
254
     * @param array $parameters
255
     *
256
     * @return $this
257
     */
258
    public function setParameters($parameters)
259
    {
260
        $this->parameters = $parameters;
261
262
        return $this;
263
    }
264
}
265