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

RecordedOn   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromDomainMessage() 0 4 1
A getRecordedOn() 0 4 1
A toString() 0 7 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