Message   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 146
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 146
ccs 36
cts 36
cp 1
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getLocale() 0 4 1
A setLocale() 0 4 1
A getMessage() 0 4 1
A setMessage() 0 4 1
A __construct() 0 6 1
A getCreatedAt() 0 4 1
A setCreatedAt() 0 4 1
A getUpdatedAt() 0 4 1
A setUpdatedAt() 0 4 1
A getStatus() 0 4 1
A setStatus() 0 6 2
A jsonSerialize() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\TranslationsBundle\Document;
13
14
use ONGR\ElasticsearchBundle\Annotation as ES;
15
16
/**
17
 * Object for translations in elasticsearch.
18
 *
19
 * @ES\Object()
20
 */
21
class Message implements \JsonSerializable
22
{
23
    const DIRTY = 'dirty';
24
    const FRESH = 'fresh';
25
26
    /**
27
     * @var string
28
     *
29
     * @ES\Property(type="keyword")
30
     */
31
    private $locale;
32
33
    /**
34
     * @var string
35
     *
36
     * @ES\Property(type="text")
37
     */
38
    private $message;
39
40
    /**
41
     * @var string
42
     *
43
     * @ES\Property(type="text")
44
     */
45
    private $status;
46
47
    /**
48
     * @var \DateTime
49
     *
50
     * @ES\Property(type="date")
51
     */
52
    private $createdAt;
53
54
    /**
55
     * @var \DateTime
56
     *
57
     * @ES\Property(type="date")
58
     */
59
    private $updatedAt;
60
61
    /**
62
     * Sets created date.
63
     */
64
    public function __construct()
65 4
    {
66
        $this->status = self::FRESH;
67 4
        $this->createdAt = new \DateTime();
68 4
        $this->updatedAt = new \DateTime();
69 4
    }
70 4
71
    /**
72
     * @return string
73
     */
74
    public function getLocale()
75 4
    {
76
        return $this->locale;
77 4
    }
78
79
    /**
80
     * @param string $locale
81
     */
82
    public function setLocale($locale)
83 4
    {
84
        $this->locale = $locale;
85 4
    }
86 4
87
    /**
88
     * @return string
89
     */
90
    public function getMessage()
91 4
    {
92
        return $this->message;
93 4
    }
94
95
    /**
96
     * @param string $message
97
     */
98
    public function setMessage($message)
99 4
    {
100
        $this->message = $message;
101 4
    }
102 4
103
    /**
104
     * @return \DateTime
105
     */
106
    public function getCreatedAt()
107 3
    {
108
        return $this->createdAt;
109 3
    }
110
111
    /**
112
     * @param \DateTime $createdAt
113
     */
114
    public function setCreatedAt($createdAt)
115 1
    {
116
        $this->createdAt = $createdAt;
117 1
    }
118 1
119
    /**
120
     * @return \DateTime
121
     */
122
    public function getUpdatedAt()
123 3
    {
124
        return $this->updatedAt;
125 3
    }
126
127
    /**
128
     * @param \DateTime $updatedAt
129
     */
130
    public function setUpdatedAt($updatedAt)
131 1
    {
132
        $this->updatedAt = $updatedAt;
133 1
    }
134 1
135
    /**
136
     * @return string
137
     */
138
    public function getStatus()
139 4
    {
140
        return $this->status;
141 4
    }
142
143
    /**
144
     * @param string $status
145
     */
146
    public function setStatus($status)
147 1
    {
148
        if (in_array($status, (new \ReflectionObject($this))->getConstants())) {
149 1
            $this->status = $status;
150 1
        }
151
    }
152 1
153
    /**
154
     * {@inheritdoc}
155
     */
156
    public function jsonSerialize()
157 1
    {
158
        return [
159
            'message' => $this->getMessage(),
160 1
            'status' => $this->getStatus(),
161 1
            'locale' => $this->getLocale(),
162 1
            'createdAt' => $this->getCreatedAt()->format('Y-m-d H:i:s'),
163 1
            'updatedAt' => $this->getUpdatedAt()->format('Y-m-d H:i:s'),
164
        ];
165
    }
166
}
167