Contact   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 144
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 0
dl 0
loc 144
ccs 18
cts 42
cp 0.4286
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A withName() 0 7 1
A getEmail() 0 4 1
A setEmail() 0 7 1
A getPhone() 0 4 1
A setPhone() 0 7 1
A getWww() 0 4 1
A setWww() 0 7 1
A toArray() 0 19 5
A createFromArray() 0 10 1
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 (null !== $this->name) {
122 1
            $data['name'] = $this->name;
123
        }
124 1
        if (null !== $this->email) {
125 1
            $data['email'] = $this->email;
126
        }
127 1
        if (null !== $this->phone) {
128 1
            $data['phone'] = $this->phone;
129
        }
130
131 1
        if (null !== $this->www) {
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