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

TimestampPropertyFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 14
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromTimestamp() 0 9 1
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