Completed
Push — master ( 25dcf6...2c47a8 )
by Tobias
02:51
created

Message::setDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[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 Translation\Common\Model;
13
14
/**
15
 * A object representation of a translation in a specific language.
16
 *
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
final class Message
20
{
21
    /**
22
     * @var string
23
     *
24
     * The domain the message belongs to
25
     */
26
    private $domain;
27
28
    /**
29
     * @var string
30
     *
31
     * The key/phrase you write in the source code
32
     */
33
    private $key;
34
35
    /**
36
     * @var string
37
     *
38
     * The locale the translations is on
39
     */
40
    private $locale;
41
42
    /**
43
     * @var string
44
     *
45
     * The translated string. This is the preview of the message. Ie no placeholders is visible.
46
     */
47
    private $translation;
48
49
    /**
50
     * Key value array with metadata.
51
     *
52
     * @var array
53
     */
54
    private $meta = [];
55
56
    /**
57
     * @param string $key
58
     * @param string $domain
59
     * @param string $locale
60
     * @param string $translation
61
     * @param array  $meta
62
     */
63 2
    public function __construct($key = '', $domain = '', $locale = '', $translation = '', array $meta = [])
64
    {
65 2
        $this->key = $key;
66 2
        $this->domain = $domain;
67 2
        $this->locale = $locale;
68 2
        $this->translation = $translation;
69 2
        $this->meta = $meta;
70 2
    }
71
72
    /**
73
     * @return string
74
     */
75 1
    public function getDomain()
76
    {
77 1
        return $this->domain;
78
    }
79
80
    /**
81
     * @param string $domain
82
     *
83
     * @return Message
84
     */
85 1
    public function setDomain($domain)
86
    {
87 1
        $this->domain = $domain;
88
89 1
        return $this;
90
    }
91
92
    /**
93
     * @return string
94
     */
95 1
    public function getKey()
96
    {
97 1
        return $this->key;
98
    }
99
100
    /**
101
     * @param string $key
102
     *
103
     * @return Message
104
     */
105 1
    public function setKey($key)
106
    {
107 1
        $this->key = $key;
108
109 1
        return $this;
110
    }
111
112
    /**
113
     * @return string
114
     */
115 1
    public function getLocale()
116
    {
117 1
        return $this->locale;
118
    }
119
120
    /**
121
     * @param string $locale
122
     *
123
     * @return Message
124
     */
125 1
    public function setLocale($locale)
126
    {
127 1
        $this->locale = $locale;
128
129 1
        return $this;
130
    }
131
132
    /**
133
     * @return string
134
     */
135 1
    public function getTranslation()
136
    {
137 1
        return $this->translation;
138
    }
139
140
    /**
141
     * @param string $translation
142
     *
143
     * @return Message
144
     */
145 1
    public function setTranslation($translation)
146
    {
147 1
        $this->translation = $translation;
148
149 1
        return $this;
150
    }
151
152
    /**
153
     * @return array
154
     */
155 1
    public function getAllMeta()
156
    {
157 1
        return $this->meta;
158
    }
159
160
    /**
161
     * @param array $meta
162
     *
163
     * @return Message
164
     */
165 1
    public function setMeta(array $meta)
166
    {
167 1
        $this->meta = $meta;
168
169 1
        return $this;
170
    }
171
172
    /**
173
     * @param array $meta
0 ignored issues
show
Bug introduced by
There is no parameter named $meta. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
174
     *
175
     * @return Message
176
     */
177 1
    public function addMeta($key, $value)
178
    {
179 1
        $this->meta[$key] = $value;
180
181 1
        return $this;
182
    }
183
184
    /**
185
     * @param string $key
186
     *
187
     * @return mixed|null
188
     */
189 1
    public function getMeta($key)
190
    {
191 1
        if (isset($this->meta[$key])) {
192 1
            return $this->meta[$key];
193
        }
194
195 1
        return;
196
    }
197
}
198