Completed
Push — master ( 3fbd33...51cff9 )
by David
02:08
created

Domain::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 9.8333
cc 2
nc 2
nop 1
crap 2
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\Domain;
13
14
/**
15
 * Represents domain information in its simplest form.
16
 *
17
 * @author Sean Johnson <[email protected]>
18
 */
19
final class Domain
20
{
21
    private $createdAt;
22
    private $smtpLogin;
23
    private $name;
24
    private $smtpPassword;
25
    private $wildcard;
26
    private $spamAction;
27
    private $state;
28
29 6
    public static function create(array $data): self
30
    {
31 6
        $model = new self();
32 6
        $model->name = $data['name'] ?? null;
33 6
        $model->smtpLogin = $data['smtp_login'] ?? null;
34 6
        $model->smtpPassword = $data['smtp_password'] ?? null;
35 6
        $model->wildcard = $data['wildcard'] ?? null;
36 6
        $model->spamAction = $data['spam_action'] ?? null;
37 6
        $model->state = $data['state'] ?? null;
38 6
        $model->createdAt = isset($data['created_at']) ? new \DateTimeImmutable($data['created_at']) : null;
39
40 6
        return $model;
41
    }
42
43 6
    private function __construct()
44
    {
45 6
    }
46
47 2
    public function getName(): ?string
48
    {
49 2
        return $this->name;
50
    }
51
52 1
    public function getSmtpUsername(): ?string
53
    {
54 1
        return $this->smtpLogin;
55
    }
56
57 1
    public function getSmtpPassword(): ?string
58
    {
59 1
        return $this->smtpPassword;
60
    }
61
62 1
    public function isWildcard(): ?bool
63
    {
64 1
        return $this->wildcard;
65
    }
66
67 1
    public function getSpamAction(): ?string
68
    {
69 1
        return $this->spamAction;
70
    }
71
72 1
    public function getState(): ?string
73
    {
74 1
        return $this->state;
75
    }
76
77 1
    public function getCreatedAt(): \DateTimeImmutable
78
    {
79 1
        return $this->createdAt;
80
    }
81
}
82