| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class Timestamp |
||
| 15 | { |
||
| 16 | private $seconds; |
||
| 17 | private $nanoseconds; |
||
| 18 | |||
| 19 | 13 | public function __construct(int $seconds, int $nanoseconds = 0) |
|
| 20 | { |
||
| 21 | 13 | $this->seconds = $seconds; |
|
| 22 | 13 | $this->nanoseconds = $nanoseconds; |
|
| 23 | 13 | } |
|
| 24 | |||
| 25 | 1 | public static function now() : self |
|
| 26 | { |
||
| 27 | 1 | $date = new \DateTime(); |
|
| 28 | |||
| 29 | 1 | return new self($date->getTimestamp(), (int) $date->format('u') * 1000); |
|
| 30 | } |
||
| 31 | |||
| 32 | 1 | public static function fromDateTime(\DateTimeInterface $date) : self |
|
| 35 | } |
||
| 36 | |||
| 37 | 12 | public function getSeconds() : int |
|
| 38 | { |
||
| 39 | 12 | return $this->seconds; |
|
| 40 | } |
||
| 41 | |||
| 42 | 12 | public function getNanoseconds() : int |
|
| 45 | } |
||
| 46 | } |
||
| 47 |