Failed Conditions
Push — issue#666 ( f415d0...521a08 )
by Guilherme
12:02
created

Statistics::getTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\StatsBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use JMS\Serializer\Annotation as JMS;
15
16
/**
17
 * Statistics
18
 *
19
 * @ORM\Entity(repositoryClass="LoginCidadao\StatsBundle\Entity\StatisticsRepository")
20
 * @ORM\Table(name="statistics",indexes={
21
 *      @ORM\Index(name="idx_timestamp_index_key", columns={"stats_timestamp", "stats_index", "stats_key"}),
22
 *      @ORM\Index(name="idx_timestamp_index", columns={"stats_timestamp", "stats_index"}),
23
 *      @ORM\Index(name="idx_timestamp_key", columns={"stats_timestamp", "stats_key"}),
24
 *      @ORM\Index(name="idx_index", columns={"stats_index"}),
25
 *      @ORM\Index(name="idx_key", columns={"stats_key"}),
26
 * })
27
 */
28
class Statistics
29
{
30
    /**
31
     * @var integer
32
     *
33
     * @ORM\Column(name="id", type="integer")
34
     * @ORM\Id
35
     * @ORM\GeneratedValue(strategy="AUTO")
36
     */
37
    private $id;
38
39
    /**
40
     * @var \DateTime
41
     *
42
     * @ORM\Column(name="stats_timestamp", type="datetime")
43
     */
44
    private $timestamp;
45
46
    /**
47
     * @var string
48
     *
49
     * @ORM\Column(name="stats_index", type="string", length=255)
50
     * @JMS\Groups({"date","datetime"})
51
     */
52
    private $index;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="stats_key", type="string", length=255)
58
     * @JMS\Groups({"date","datetime"})
59
     */
60
    private $key;
61
62
    /**
63
     * @var integer
64
     *
65
     * @ORM\Column(name="stats_value", type="integer")
66
     * @JMS\Groups({"date","datetime"})
67
     */
68
    private $value;
69
70
    /**
71
     * Get id
72
     *
73
     * @return integer 
74
     */
75 1
    public function getId()
76
    {
77 1
        return $this->id;
78
    }
79
80
    /**
81
     * Set timestamp
82
     *
83
     * @param \DateTime $timestamp
84
     * @return Statistics
85
     */
86 3
    public function setTimestamp($timestamp)
87
    {
88 3
        $this->timestamp = $timestamp;
89
90 3
        return $this;
91
    }
92
93
    /**
94
     * Get timestamp
95
     *
96
     * @return \DateTime 
97
     */
98 1
    public function getTimestamp()
99
    {
100 1
        return $this->timestamp;
101
    }
102
103
    /**
104
     * Set index
105
     *
106
     * @param string $index
107
     * @return Statistics
108
     */
109 3
    public function setIndex($index)
110
    {
111 3
        $this->index = $index;
112
113 3
        return $this;
114
    }
115
116
    /**
117
     * Get index
118
     *
119
     * @return string 
120
     */
121 1
    public function getIndex()
122
    {
123 1
        return $this->index;
124
    }
125
126
    /**
127
     * Set key
128
     *
129
     * @param string $key
130
     * @return Statistics
131
     */
132 3
    public function setKey($key)
133
    {
134 3
        $this->key = $key;
135
136 3
        return $this;
137
    }
138
139
    /**
140
     * Get key
141
     *
142
     * @return string 
143
     */
144 1
    public function getKey()
145
    {
146 1
        return $this->key;
147
    }
148
149
    /**
150
     * Set value
151
     *
152
     * @param integer $value
153
     * @return Statistics
154
     */
155 3
    public function setValue($value)
156
    {
157 3
        $this->value = $value;
158
159 3
        return $this;
160
    }
161
162
    /**
163
     * Get value
164
     *
165
     * @return integer 
166
     */
167 1
    public function getValue()
168
    {
169 1
        return $this->value;
170
    }
171
172
    /**
173
     * @JMS\VirtualProperty
174
     * @JMS\SerializedName("timestamp")
175
     * @JMS\Groups({"date"})
176
     * @return string
177
     */
178 1
    public function getDate()
179
    {
180 1
        return $this->getTimestamp()->format('Y-m-d');
181
    }
182
183
    /**
184
     * @JMS\VirtualProperty
185
     * @JMS\SerializedName("timestamp")
186
     * @JMS\Groups({"datetime"})
187
     * @return string
188
     */
189 1
    public function getDateTime()
190
    {
191 1
        return $this->getTimestamp()->format('Y-m-d H:i:s');
192
    }
193
}
194