MicrotimeTrait::setWhenAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Dtc\QueueBundle\Model;
4
5
use Dtc\QueueBundle\Util\Util;
6
7
trait MicrotimeTrait
8
{
9 34
    public function setWhenAt(\DateTime $whenAt)
10
    {
11 34
        parent::setWhenAt($whenAt);
12
13 34
        return $this->setWhenUs(Util::getMicrotimeIntegerFormat($whenAt));
14
    }
15
16
    /**
17
     * @return \DateTime|null
18
     */
19 50
    public function getWhenAt()
20
    {
21 50
        $whenUs = isset($this->whenUs) ? $this->whenUs : null;
22 50
        if ($whenUs) {
23 33
            return Util::getDateTimeFromDecimalFormat($whenUs);
24
        }
25
26 47
        return null;
27
    }
28
29
    /**
30
     * @param string
31
     */
32 36
    public function setWhenUs($whenUs)
33
    {
34 36
        $this->whenUs = $whenUs;
0 ignored issues
show
Bug Best Practice introduced by
The property whenUs does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
36 36
        return $this;
37
    }
38
39
    /**
40
     * @param string
41
     */
42 47
    public function getWhenUs()
43
    {
44 47
        return isset($this->whenUs) ? $this->whenUs : null;
45
    }
46
}
47