Completed
Push — master ( c76232...ce4950 )
by Matthew
27:26 queued 01:28
created

MicrotimeTrait::setWhenUs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Dtc\QueueBundle\Model;
4
5
use Dtc\QueueBundle\Util\Util;
6
7
trait MicrotimeTrait
8
{
9 23
    public function setWhenAt(\DateTime $whenAt)
10
    {
11 23
        parent::setWhenAt($whenAt);
12
13 23
        return $this->setWhenUs(Util::getMicrotimeDecimalFormat($whenAt));
14
    }
15
16
    /**
17
     * @return \DateTime|null
18
     */
19 40
    public function getWhenAt()
20
    {
21 40
        $whenUs = isset($this->whenUs) ? $this->whenUs : null;
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...
22 40
        if ($whenUs) {
23 22
            return Util::getDateTimeFromDecimalFormat($whenUs);
24
        }
25
26 37
        return null;
27
    }
28
29
    /**
30
     * @param string
31
     */
32 25
    public function setWhenUs($whenUs)
33
    {
34 25
        $this->whenUs = $whenUs;
35
36 25
        return $this;
37
    }
38
39
    /**
40
     * @param string
41
     */
42 36
    public function getWhenUs()
43
    {
44 36
        return isset($this->whenUs) ? $this->whenUs : null;
45
    }
46
}
47