Completed
Pull Request — master (#30)
by Matthew
07:24
created

MicrotimeTrait::getWhenAt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
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 21
    public function setWhenAt(\DateTime $whenAt)
10
    {
11 21
        parent::setWhenAt($whenAt);
12
13 21
        return $this->setWhenUs(Util::getMicrotimeDecimalFormat($whenAt));
14
    }
15
16
    /**
17
     * @return \DateTime|null
18
     */
19 38
    public function getWhenAt()
20
    {
21 38
        if ($this->whenUs) {
22 20
            return Util::getDateTimeFromDecimalFormat($this->whenUs);
0 ignored issues
show
Bug introduced by
The property whenUs does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
        }
24
25 35
        return null;
26
    }
27
28
    /**
29
     * @param string
30
     */
31 23
    public function setWhenUs($whenUs)
32
    {
33 23
        $this->whenUs = $whenUs;
34
35 23
        return $this;
36
    }
37
38
    /**
39
     * @param string
40
     */
41 34
    public function getWhenUs()
42
    {
43 34
        return $this->whenUs;
44
    }
45
}
46