Completed
Pull Request — master (#30)
by Matthew
16:57
created

MicrotimeTrait::getWhenUs()   A

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 2
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 Dtc\QueueBundle\Model;
4
5
use Dtc\QueueBundle\Util\Util;
6
7
trait MicrotimeTrait
8
{
9
    protected $whenUs;
10
11
    public function setWhenAt(\DateTime $whenAt)
12
    {
13
        parent::setWhenAt($whenAt);
14
15
        return $this->setWhenUs(Util::getMicrotimeDecimalFormat($whenAt));
16
    }
17
18
    /**
19
     * @return \DateTime|null
20
     */
21
    public function getWhenAt()
22
    {
23
        if ($this->whenUs) {
24
            return Util::getDateTimeFromDecimalFormat($this->whenUs);
25
        }
26
27
        return null;
28
    }
29
30
    /**
31
     * @param string
32
     */
33
    public function setWhenUs($whenUs)
34
    {
35
        $this->whenUs = $whenUs;
36
37
        return $this;
38
    }
39
40
    /**
41
     * @param string
42
     */
43
    public function getWhenUs()
44
    {
45
        return $this->whenUs;
46
    }
47
}
48