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

Member::create()   A

Complexity

Conditions 5
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6111
c 0
b 0
f 0
cc 5
nc 1
nop 1
crap 5
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