Completed
Push — master ( a79b8b...cbb135 )
by Tobias
02:50
created

Unsubscribe::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\Suppression\Unsubscribe;
13
14
/**
15
 * @author Sean Johnson <[email protected]>
16
 */
17
class Unsubscribe
18
{
19
    private $address;
20
    private $createdAt;
21
    private $tags = [];
22
23 2
    private function __construct()
24
    {
25 2
    }
26
27 2
    public static function create(array $data): self
28
    {
29 2
        $model = new self();
30 2
        $model->tags = $data['tags'] ?? [];
31 2
        $model->address = $data['address'] ?? null;
32 2
        $model->createdAt = isset($data['created_at']) ? new \DateTimeImmutable($data['created_at']) : null;
33
34 2
        return $model;
35
    }
36
37
    public function getAddress(): ?string
38
    {
39
        return $this->address;
40
    }
41
42
    public function getCreatedAt(): ?\DateTimeImmutable
43
    {
44
        return $this->createdAt;
45
    }
46
47 2
    public function getTags(): array
48
    {
49 2
        return $this->tags;
50
    }
51
}
52