Completed
Pull Request — master (#144)
by Markus
02:45 queued 01:47
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
/*
4
 * This file is part of the eluceo/iCal package.
5
 *
6
 * (c) 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\Presentation\Factory\Property;
13
14
use Eluceo\iCal\Domain\ValueObject\Timestamp;
15
use Eluceo\iCal\Presentation\Component\Property;
16
use Eluceo\iCal\Presentation\Component\Property\Value\StringValue;
17
18
class TimestampPropertyFactory
19
{
20
    private const FORMAT = 'Ymd\THis\Z';
21
22
    public function fromTimestamp(string $name, Timestamp $timestamp): Property
23
    {
24
        $dateTime = $timestamp->getDateTime()->setTimezone(new \DateTimeZone('UTC'));
25
26
        return Property::create(
27
            $name,
28
            StringValue::fromString($dateTime->format(static::FORMAT))
29
        );
30
    }
31
}
32