Completed
Pull Request — master (#6)
by Tobias
02:02
created

Message   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 14
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 179
ccs 0
cts 65
cp 0
rs 10

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getDomain() 0 4 1
A setDomain() 0 6 1
A getId() 0 4 1
A setId() 0 6 1
A getLocale() 0 4 1
A setLocale() 0 6 1
A getTranslation() 0 4 1
A setTranslation() 0 6 1
A getAllMeta() 0 4 1
A setMeta() 0 6 1
A addMeta() 0 6 1
A getMeta() 0 8 2
1
<?php
2
3
namespace Translation\Common\Model;
4
5
/**
6
 * A object representation of a translation in a specific language.
7
 *
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
class Message
11
{
12
    /**
13
     * @var string
14
     *
15
     * The domain the message belongs to
16
     */
17
    private $domain;
18
19
    /**
20
     * @var string
21
     *
22
     * The key/phrase you write in the source code
23
     */
24
    private $id;
25
26
    /**
27
     * @var string
28
     *
29
     * The locale the translations is on
30
     */
31
    private $locale;
32
33
    /**
34
     * @var string
35
     *
36
     * The translated string. This is the preview of the message. Ie no placeholders is visible.
37
     */
38
    private $translation;
39
40
    /**
41
     * Key value array with metadata.
42
     *
43
     * @var array
44
     */
45
    private $meta = [];
46
47
    /**
48
     * @param string $domain
49
     * @param string $id
50
     * @param string $locale
51
     * @param string $translation
52
     * @param array  $meta
53
     */
54
    public function __construct($domain = '', $id = '', $locale = '', $translation = '', array $meta = [])
55
    {
56
        $this->domain = $domain;
57
        $this->id = $id;
58
        $this->locale = $locale;
59
        $this->translation = $translation;
60
        $this->meta = $meta;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getDomain()
67
    {
68
        return $this->domain;
69
    }
70
71
    /**
72
     * @param string $domain
73
     *
74
     * @return Message
75
     */
76
    public function setDomain($domain)
77
    {
78
        $this->domain = $domain;
79
80
        return $this;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getId()
87
    {
88
        return $this->id;
89
    }
90
91
    /**
92
     * @param string $id
93
     *
94
     * @return Message
95
     */
96
    public function setId($id)
97
    {
98
        $this->id = $id;
99
100
        return $this;
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getLocale()
107
    {
108
        return $this->locale;
109
    }
110
111
    /**
112
     * @param string $locale
113
     *
114
     * @return Message
115
     */
116
    public function setLocale($locale)
117
    {
118
        $this->locale = $locale;
119
120
        return $this;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getTranslation()
127
    {
128
        return $this->translation;
129
    }
130
131
    /**
132
     * @param string $translation
133
     *
134
     * @return Message
135
     */
136
    public function setTranslation($translation)
137
    {
138
        $this->translation = $translation;
139
140
        return $this;
141
    }
142
143
    /**
144
     * @return array
145
     */
146
    public function getAllMeta()
147
    {
148
        return $this->meta;
149
    }
150
151
    /**
152
     * @param array $meta
153
     *
154
     * @return Message
155
     */
156
    public function setMeta(array $meta)
157
    {
158
        $this->meta = $meta;
159
160
        return $this;
161
    }
162
163
    /**
164
     * @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...
165
     *
166
     * @return Message
167
     */
168
    public function addMeta($key, $value)
169
    {
170
        $this->meta[$key] = $value;
171
172
        return $this;
173
    }
174
175
    /**
176
     * @param string $key
177
     *
178
     * @return mixed|null
179
     */
180
    public function getMeta($key)
181
    {
182
        if (isset($this->meta[$key])) {
183
            return $this->meta[$key];
184
        }
185
186
        return;
187
    }
188
}
189