Completed
Branch master (c7b6b7)
by Pierre
19:40 queued 09:38
created

Conversion::setUnixMicroTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Popy\Calendar\Converter;
4
5
use DateTimeInterface;
6
use Popy\Calendar\ValueObject\DateRepresentationInterface;
7
8
class Conversion
9
{
10
    /**
11
     * Date to convert.
12
     *
13
     * @var DateRepresentationInterface
14
     */
15
    protected $from;
16
17
    /**
18
     * Converted date (being built). Holds the date being built during a
19
     * conversion from unix time, and an eventually completed copy of the
20
     * source date.
21
     *
22
     * @var DateRepresentationInterface|null
23
     */
24
    protected $to;
25
26
    /**
27
     * Remaining/Accumulated unix time during conversion from/to timestamp.
28
     *
29
     * @var integer|null
30
     */
31
    protected $unixTime;
32
33
    /**
34
     * Remaining/Accumulated unix microtime during conversion from/to timestamp.
35
     *
36
     * @var integer|null
37
     */
38
    protected $unixMicroTime;
39
40
    /**
41
     * Class constructor.
42
     *
43
     * @param DateRepresentationInterface      $from
44
     * @param DateRepresentationInterface|null $to
45
     */
46
    public function __construct(DateRepresentationInterface $from, DateRepresentationInterface $to = null)
47
    {
48
        $this->from = $from;
49
        $this->to = $to;
50
        $this->unixTime = $from->getUnixTime();
51
        $this->unixMicroTime = $from->getUnixMicroTime();
52
    }
53
54
    /**
55
     * Gets the Date to convert.
56
     *
57
     * @return DateRepresentationInterface
58
     */
59
    public function getFrom()
60
    {
61
        return $this->from;
62
    }
63
64
    /**
65
     * Gets the Converted date.
66
     *
67
     * @return DateRepresentationInterface|null
68
     */
69
    public function getTo()
70
    {
71
        return $this->to;
72
    }
73
74
    /**
75
     * Sets the Converted date.
76
     *
77
     * @param DateRepresentationInterface $to the to
78
     *
79
     * @return self|null
80
     */
81
    public function setTo(DateRepresentationInterface $to)
82
    {
83
        $this->to = $to;
84
85
        return $this;
86
    }
87
88
    /**
89
     * Gets unix time.
90
     *
91
     * @return integer
92
     */
93
    public function getUnixTime()
94
    {
95
        return $this->unixTime;
96
    }
97
98
    /**
99
     * Sets unix time.
100
     *
101
     * @param integer $unixTime the unix time
102
     *
103
     * @return self
104
     */
105
    public function setUnixTime($unixTime)
106
    {
107
        $this->unixTime = $unixTime;
108
109
        return $this;
110
    }
111
112
    /**
113
     * Gets unix micro time.
114
     *
115
     * @return integer|null
116
     */
117
    public function getUnixMicroTime()
118
    {
119
        return $this->unixMicroTime;
120
    }
121
122
    /**
123
     * Sets unix micro time.
124
     *
125
     * @param integer $unixMicroTime the unix microtime
126
     *
127
     * @return self
128
     */
129
    public function setUnixMicroTime($unixMicroTime)
130
    {
131
        $this->unixMicroTime = $unixMicroTime;
132
133
        return $this;
134
    }
135
}
136