Completed
Pull Request — master (#337)
by Luc
06:44
created

RecordedOn::fromDomainMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3;
4
5
use Broadway\Domain\DomainMessage;
6
use Broadway\Domain\DateTime;
7
8
class RecordedOn
9
{
10
    /**
11
     * @var DateTime
12
     */
13
    private $recorded;
14
15
    /**
16
     * ModifiedDateTime constructor.
17
     * @param DateTime $recorded
18
     */
19
    public function __construct(DateTime $recorded)
20
    {
21
        $this->recorded = $recorded;
22
    }
23
24
    /**
25
     * @param DomainMessage $domainMessage
26
     * @return RecordedOn
27
     */
28
    public static function fromDomainMessage(DomainMessage $domainMessage)
29
    {
30
        return new self($domainMessage->getRecordedOn());
31
    }
32
33
    /**
34
     * @return DateTime
35
     */
36
    public function getRecordedOn()
37
    {
38
        return $this->recorded;
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function toString()
45
    {
46
        return \DateTime::createFromFormat(
47
            DateTime::FORMAT_STRING,
48
            $this->recorded->toString()
49
        )->format('c');
50
    }
51
}
52