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

MicrotimeTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 40
ccs 13
cts 13
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 9 3
A setWhenUs() 0 6 1
A getWhenUs() 0 4 2
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