Completed
Push — master ( 9621c0...4bb787 )
by Tobias
01:47
created

Contact::setEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Setting;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class Contact implements CreatableFromArray
13
{
14
    /**
15
     * @var string
16
     */
17
    private $name;
18
19
    /**
20
     * @var string
21
     */
22
    private $email;
23
24
    /**
25
     * @var string
26
     */
27
    private $phone;
28
29
    /**
30
     * @var string
31
     */
32
    private $www;
33
34
    /**
35
     * @return string
36
     */
37
    public function getName()
38
    {
39
        return $this->name;
40
    }
41
42
    /**
43
     * @param string $name
44
     *
45
     * @return Contact
46
     */
47
    public function withName(string $name)
48
    {
49
        $new = clone $this;
50
        $new->name = $name;
51
52
        return $new;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getEmail()
59
    {
60
        return $this->email;
61
    }
62
63
    /**
64
     * @param string $email
65
     *
66
     * @return Contact
67
     */
68
    public function setEmail(string $email)
69
    {
70
        $new = clone $this;
71
        $new->email = $email;
72
73
        return $new;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getPhone()
80
    {
81
        return $this->phone;
82
    }
83
84
    /**
85
     * @param string $phone
86
     *
87
     * @return Contact
88
     */
89
    public function setPhone(string $phone)
90
    {
91
        $new = clone $this;
92
        $new->phone = $phone;
93
94
        return $new;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getWww(): string
101
    {
102
        return $this->phone;
103
    }
104
105
    /**
106
     * @param string $www
107
     *
108
     * @return Contact
109
     */
110
    public function setWww(string $www)
111
    {
112
        $new = clone $this;
113
        $new->www = $www;
114
115
        return $new;
116
    }
117
118 1
    public function toArray()
119
    {
120 1
        $data = [];
121 1
        if ($this->name !== null) {
122 1
            $data['name'] = $this->name;
123
        }
124 1
        if ($this->email !== null) {
125 1
            $data['email'] = $this->email;
126
        }
127 1
        if ($this->phone !== null) {
128 1
            $data['phone'] = $this->phone;
129
        }
130
131 1
        if ($this->www !== null) {
132 1
            $data['www'] = $this->www;
133
        }
134
135 1
        return $data;
136
    }
137
138
    /**
139
     * Create an API response object from the HTTP response from the API server.
140
     *
141
     * @param array $data
142
     *
143
     * @return Contact
144
     */
145 2
    public static function createFromArray(array $data)
146
    {
147 2
        $contact = new self();
148 2
        $contact->name = $data['name'] ?? null;
149 2
        $contact->email = $data['email'] ?? null;
150 2
        $contact->phone = $data['phone'] ?? null;
151 2
        $contact->www = $data['www'] ?? null;
152
153 2
        return $contact;
154
    }
155
}
156