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

MicrotimeTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 39
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setWhenAt() 0 6 1
A getWhenAt() 0 8 2
A setWhenUs() 0 6 1
A getWhenUs() 0 4 1
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