Completed
Push — master ( 4b0611...da5ccd )
by Tobias
06:14 queued 03:25
created

Member   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 80.95%

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 0
dl 0
loc 77
ccs 17
cts 21
cp 0.8095
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 5
A __construct() 0 7 1
A getName() 0 4 1
A getAddress() 0 4 1
A getVars() 0 4 1
A isSubscribed() 0 4 1
1
<?php
2
3
/*
4
 * Copyright (C) 2013 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Model\MailingList\Member;
11
12
use Mailgun\Model\ApiResponse;
13
14
final class Member implements ApiResponse
15
{
16
    /**
17
     * @var string
18
     */
19
    private $name;
20
21
    /**
22
     * @var string
23
     */
24
    private $address;
25
26
    /**
27
     * @var array
28
     */
29
    private $vars;
30
31
    /**
32
     * @var bool
33
     */
34
    private $subscribed;
35
36
    /**
37
     * @param array $data
38
     *
39
     * @return self
40
     */
41 4
    public static function create(array $data)
42
    {
43 4
        return new self(
44 4
            isset($data['name']) ? $data['name'] : null,
45 4
            isset($data['address']) ? $data['address'] : null,
46 4
            isset($data['vars']) ? $data['vars'] : [],
47 4
            isset($data['subscribed']) ? (bool) $data['subscribed'] : null
48 4
        );
49
    }
50
51 4
    private function __construct($name, $address, $vars = [], $subscribed = null)
52
    {
53 4
        $this->name = $name;
54 4
        $this->address = $address;
55 4
        $this->vars = $vars;
56 4
        $this->subscribed = $subscribed;
57 4
    }
58
59
    /**
60
     * @return string
61
     */
62 3
    public function getName()
63
    {
64 3
        return $this->name;
65
    }
66
67
    /**
68
     * @return string
69
     */
70 1
    public function getAddress()
71
    {
72 1
        return $this->address;
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    public function getVars()
79
    {
80
        return $this->vars;
81
    }
82
83
    /**
84
     * @return bool
85
     */
86
    public function isSubscribed()
87
    {
88
        return $this->subscribed;
89
    }
90
}
91