Completed
Pull Request — master (#144)
by Markus
01:01
created

Timestamp   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromDateTimeInterface() 0 9 1
A fromCurrentTime() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the eluceo/iCal package.
5
 *
6
 * (c) 2019 Markus Poerschke <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Eluceo\iCal\Domain\ValueObject;
13
14
use DateTimeImmutable as PhpDateTimeImmutable;
15
use DateTimeInterface as PhpDateTimeInterface;
16
17
class Timestamp extends PointInTime
18
{
19
    public static function fromDateTimeInterface(PhpDateTimeInterface $dateTime): self
20
    {
21
        return new static(
22
            PhpDateTimeImmutable::createFromFormat(
23
                PhpDateTimeInterface::ATOM,
24
                $dateTime->format(PhpDateTimeInterface::ATOM), $dateTime->getTimezone()
25
            )
26
        );
27
    }
28
29
    public static function fromCurrentTime(): self
30
    {
31
        return static::fromDateTimeInterface(new PhpDateTimeImmutable());
32
    }
33
}
34