Completed
Pull Request — master (#384)
by Kristof
03:32
created

DomainMessageAdapter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getUserId() 0 5 1
A getRecordedDateTime() 0 4 1
1
<?php
2
3
namespace CultuurNet\UDB3;
4
5
use Broadway\Domain\DomainMessage;
6
use DateTime;
7
8
class DomainMessageAdapter
9
{
10
    /**
11
     * @var DomainMessage
12
     */
13
    private $domainMessage;
14
15
    /**
16
     * DomainMessageAdapter constructor.
17
     *
18
     * @param DomainMessage $domainMessage
19
     */
20
    public function __construct(DomainMessage $domainMessage)
21
    {
22
        $this->domainMessage = $domainMessage;
23
    }
24
25
    public function getUserId(): string
26
    {
27
        $metaData = $this->domainMessage->getMetadata()->serialize();
28
        return $metaData['user_id'] ?? '';
29
    }
30
31
    public function getRecordedDateTime(): ?DateTime
32
    {
33
        return new DateTime($this->domainMessage->getRecordedOn()->toString());
34
    }
35
}
36