DateTimeTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTime() 0 3 2
A withTime() 0 6 1
1
<?php
2
3
namespace Popy\Calendar\ValueObject\DateRepresentation;
4
5
use Popy\Calendar\ValueObject\Time;
6
7
/**
8
 * Popy\Calendar\ValueObject\DateTimeRepresentationInterface implementation.
9
 */
10
trait DateTimeTrait
11
{
12
    /**
13
     * Time.
14
     *
15
     * @var Time
16
     */
17
    protected $time;
18
19
    /**
20
     * @inheritDoc
21
     */
22
    public function getTime()
23
    {
24
        return $this->time ?: new Time();
25
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30
    public function withTime(Time $time)
31
    {
32
        $res = clone $this;
33
        $res->time = $time;
34
35
        return $res;
36
    }
37
}
38