Completed
Push — 2.x ( ea1583 )
by Markus
01:37
created

TimestampPropertyFactory::fromTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.9666
nc 1
cc 1
nop 2
1
<?php
2
3
namespace Eluceo\iCal\Presentation\Factory\Property;
4
5
use Eluceo\iCal\Domain\ValueObject\Timestamp;
6
use Eluceo\iCal\Presentation\Component\Property;
7
use Eluceo\iCal\Presentation\Component\Property\Value\StringValue;
8
9
class TimestampPropertyFactory
10
{
11
    private const FORMAT = 'Ymd\THis\Z';
12
13
    public function fromTimestamp(string $name, Timestamp $timestamp): Property
14
    {
15
        $dateTime = $timestamp->getDateTime()->setTimezone(new \DateTimeZone('UTC'));
16
17
        return Property::create(
18
            $name,
19
            StringValue::fromString($dateTime->format(static::FORMAT))
20
        );
21
    }
22
}
23