Completed
Push — master ( 4641cf...cd08d9 )
by David
02:22 queued 52s
created

MailingList   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 63
ccs 16
cts 26
cp 0.6153
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 2
A __construct() 0 3 1
A getName() 0 4 1
A getAddress() 0 4 1
A getAccessLevel() 0 4 1
A getReplyPreference() 0 4 1
A getDescription() 0 4 1
A getMembersCount() 0 4 1
A getCreatedAt() 0 4 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\MailingList;
13
14
use Mailgun\Model\ApiResponse;
15
16
final class MailingList implements ApiResponse
17
{
18
    private $name;
19
    private $address;
20
    private $accessLevel;
21
    private $replyPreference;
22
    private $description;
23
    private $membersCount;
24
    private $createdAt;
25
26 3
    public static function create(array $data): self
27
    {
28 3
        $model = new self();
29 3
        $model->name = $data['name'] ?? null;
30 3
        $model->address = $data['address'] ?? null;
31 3
        $model->accessLevel = $data['access_level'] ?? null;
32 3
        $model->replyPreference = $data['reply_preference'] ?? null;
33 3
        $model->description = $data['description'] ?? null;
34 3
        $model->membersCount = (int) ($data['members_count'] ?? 0);
35 3
        $model->createdAt = isset($data['created_at']) ? new \DateTimeImmutable($data['created_at']) : null;
36
37 3
        return $model;
38
    }
39
40 3
    private function __construct()
41
    {
42 3
    }
43
44
    public function getName(): ?string
45
    {
46
        return $this->name;
47
    }
48
49
    public function getAddress(): ?string
50
    {
51
        return $this->address;
52
    }
53
54 1
    public function getAccessLevel(): ?string
55
    {
56 1
        return $this->accessLevel;
57
    }
58
59
    public function getReplyPreference(): ?string
60
    {
61
        return $this->replyPreference;
62
    }
63
64
    public function getDescription(): ?string
65
    {
66
        return $this->description;
67
    }
68
69 2
    public function getMembersCount(): int
70
    {
71 2
        return $this->membersCount;
72
    }
73
74
    public function getCreatedAt(): \DateTimeImmutable
75
    {
76
        return $this->createdAt;
77
    }
78
}
79