Completed
Push — master ( 2994aa...19d116 )
by Patrick
08:28
created

Account   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 233
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 1

Test Coverage

Coverage 51.16%

Importance

Changes 0
Metric Value
wmc 19
lcom 4
cbo 1
dl 0
loc 233
ccs 22
cts 43
cp 0.5116
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 3
A getAccountId() 0 4 1
A getNameDetails() 0 4 1
A getDisplayName() 0 10 2
A getEmail() 0 4 1
A emailIsVerified() 0 4 2
A getProfilePhotoUrl() 0 4 1
A isDisabled() 0 4 2
A getCountry() 0 4 1
A getLocale() 0 4 1
A getReferralLink() 0 4 1
A isPaired() 0 4 2
A getAccountType() 0 4 1
1
<?php
2
namespace Dropbox\Models;
3
4
class Account extends BaseModel
5
{
6
    /**
7
     * Account ID
8
     *
9
     * @var string
10
     */
11
    protected $account_id;
12
13
    /**
14
     * User name details
15
     *
16
     * @var array
17
     */
18
    protected $name = [];
19
20
    /**
21
     * Account Email
22
     *
23
     * @var string
24
     */
25
    protected $email;
26
27
    /**
28
     * Whether the user has verified their e-mail address
29
     *
30
     * @var boolean
31
     */
32
    protected $email_verified = false;
33
34
    /**
35
     * Account Profile Pic URL
36
     *
37
     * @var string
38
     */
39
    protected $profile_photo_url;
40
41
    /**
42
     * Whether the user has been disabled
43
     *
44
     * @var boolean
45
     */
46
    protected $disabled = false;
47
48
    /**
49
     * User's two-letter country code
50
     *
51
     * @var string
52
     */
53
    protected $country;
54
55
    /**
56
     * Language of User's account
57
     *
58
     * @var string
59
     */
60
    protected $locale;
61
62
    /**
63
     * User's referral link
64
     *
65
     * @var string
66
     */
67
    protected $referral_link;
68
69
    /**
70
     * Indicates whether a work account is linked
71
     *
72
     * @var boolean
73
     */
74
    protected $is_paired = false;
75
76
    /**
77
     * User's account type
78
     *
79
     * @var string
80
     */
81
    protected $account_type;
82
83
    /**
84
     * Create a new Account instance
85
     *
86
     * @param array $data
87
     */
88 3
    public function __construct(array $data)
89
    {
90 3
        parent::__construct($data);
91
92 3
        $this->account_id = $this->getDataProperty('account_id');
93 3
        $this->name = (array) $this->getDataProperty('name');
94 3
        $this->email = $this->getDataProperty('email');
95 3
        $this->email_verified = $this->getDataProperty('email_verified');
96 3
        $this->disabled = $this->getDataProperty('disabled');
97 3
        $this->profile_photo_url = $this->getDataProperty('profile_photo_url');
98 3
        $this->locale = $this->getDataProperty('locale');
99 3
        $this->country = $this->getDataProperty('country');
100 3
        $this->referral_link = $this->getDataProperty('referral_link');
101 3
        $this->is_paired = $this->getDataProperty('is_paired');
102
103
        //Account Type
104 3
        $account_type = $this->getDataProperty('account_type');
105
106 3
        if (is_array($account_type) && !empty($account_type)) {
107 2
            $this->account_type = $account_type['.tag'];
108
        }
109 3
    }
110
111
    /**
112
     * Get Account ID
113
     *
114
     * @return string
115
     */
116 3
    public function getAccountId()
117
    {
118 3
        return $this->account_id;
119
    }
120
121
    /**
122
     * Get Account User's Name Details
123
     *
124
     * @return array
125
     */
126
    public function getNameDetails()
127
    {
128
        return $this->name;
129
    }
130
131
    /**
132
     * Get Display name
133
     *
134
     * @return string
135
     */
136 2
    public function getDisplayName()
137
    {
138 2
        $name = $this->name;
139
140 2
        if (isset($name['display_name'])) {
141 2
            return $name['display_name'];
142
        }
143
144
        return "";
145
    }
146
147
    /**
148
     * Get Account Email
149
     *
150
     * @return string
151
     */
152
    public function getEmail()
153
    {
154
        return $this->email;
155
    }
156
157
    /**
158
     * Whether account email is verified
159
     *
160
     * @return boolean
161
     */
162
    public function emailIsVerified()
163
    {
164
        return $this->email_verified ? true : false;
165
    }
166
167
    /**
168
     * Get Profile Pic URL
169
     *
170
     * @return string
171
     */
172
    public function getProfilePhotoUrl()
173
    {
174
        return $this->profile_photo_url;
175
    }
176
177
    /**
178
     * Whether acocunt has been disabled
179
     *
180
     * @return boolean
181
     */
182
    public function isDisabled()
183
    {
184
        return $this->disabled ? true : false;
185
    }
186
187
    /**
188
     * Get User's two-lettered country code
189
     *
190
     * @return string
191
     */
192
    public function getCountry()
193
    {
194
        return $this->country;
195
    }
196
197
    /**
198
     * Get account language
199
     *
200
     * @return string
201
     */
202
    public function getLocale()
203
    {
204
        return $this->locale;
205
    }
206
207
    /**
208
     * Get user's referral link
209
     *
210
     * @return string
211
     */
212
    public function getReferralLink()
213
    {
214
        return $this->referral_link;
215
    }
216
217
    /**
218
     * Whether work account is paired
219
     *
220
     * @return boolean
221
     */
222
    public function isPaired()
223
    {
224
        return $this->is_paired ? true : false;
225
    }
226
227
    /**
228
     * Get Account Type
229
     *
230
     * @return string
231
     */
232
    public function getAccountType()
233
    {
234
        return $this->account_type;
235
    }
236
}
237