Completed
Push — master ( ac056e...2fe264 )
by David
04:27 queued 01:15
created

MailingList   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 65.22%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 56
ccs 15
cts 23
cp 0.6522
rs 10
c 0
b 0
f 0

8 Methods

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