Completed
Push — master ( 4517c4...dc88ca )
by
unknown
05:54
created

Account   F

Complexity

Total Complexity 56

Size/Duplication

Total Lines 787
Duplicated Lines 8.77 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 69
loc 787
rs 1.3333
c 0
b 0
f 0
wmc 56
lcom 1
cbo 2

51 Methods

Rating   Name   Duplication   Size   Complexity  
A addAlternativePhone() 0 11 1
A addAddress() 16 16 1
A get() 0 4 1
A create() 0 4 1
A initialize() 0 8 1
A getId() 0 4 1
A checkExistence() 0 14 3
A getAccessToken() 0 4 1
A getChannelId() 0 4 1
A getLogin() 0 4 1
A getAddress() 0 4 1
A getFullname() 0 4 1
A getBirthDate() 0 4 1
A getPhoneAreaCode() 0 4 1
A getPhoneCountryCode() 0 4 1
A getPhoneNumber() 0 4 1
A getTaxDocumentType() 0 4 1
A getTaxDocumentNumber() 0 4 1
A getIdentityDocumentNumber() 0 4 1
A getIdentityDocumentIssuer() 0 4 1
A getIdentityDocumentIssueDate() 0 4 1
A getIdentityDocumentType() 0 4 1
A getAlternativePhones() 0 4 1
A getCompany() 0 4 1
A getEmailAddress() 0 4 1
A getEmailConfirmed() 0 4 1
A getType() 0 4 1
A getTransparentAccount() 0 4 1
A getCreatedAt() 0 4 1
A populate() 0 55 1
A setEmail() 0 6 1
A setName() 0 6 1
A setLastName() 0 6 1
A setBirthDate() 10 10 2
A setTaxDocument() 8 8 1
A setPhone() 9 9 1
A setIdentityDocument() 0 10 1
A setNationality() 0 6 1
A setBirthPlace() 0 6 1
A setParentsName() 0 8 1
A setSite() 0 6 1
A setTransparentAccount() 0 6 1
A setBusinessSegment() 0 6 1
A setCompanyName() 0 8 1
A initializeCompany() 0 6 2
A setCompanyOpeningDate() 0 10 2
A setCompanyTaxDocument() 9 9 1
A setCompanyMainActivity() 0 9 1
A setCompanyAddress() 17 17 1
A setCompanyPhone() 0 10 1
A setType() 0 6 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like Account often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Account, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Moip\Resource;
4
5
use Moip\Exceptions\ValidationException;
6
use stdClass;
7
8
/**
9
 * Class Account.
10
 */
11
class Account extends MoipResource
12
{
13
    /**
14
     * Path accounts API.
15
     *
16
     * @const string
17
     */
18
    const PATH = 'accounts';
19
20
    /**
21
     * Standard country .
22
     *
23
     * @const string
24
     */
25
    const ADDRESS_COUNTRY = 'BRA';
26
27
    /**
28
     * Standard document type.
29
     *
30
     * @const string
31
     */
32
    const TAX_DOCUMENT = 'CPF';
33
34
    /**
35
     * Standard company document type.
36
     *
37
     * @const string
38
     */
39
    const COMPANY_TAX_DOCUMENT = 'CNPJ';
40
41
    /**
42
     * Default Account Type.
43
     *
44
     * @var string
45
     */
46
    const ACCOUNT_TYPE = 'MERCHANT';
47
48
    /**
49
     * Initialize a new instance.
50
     */
51
    public function initialize()
52
    {
53
        $this->data = new stdClass();
54
        $this->data->email = new stdClass();
55
        $this->data->person = new stdClass();
56
        $this->data->person->alternativePhones = [];
57
        $this->data->type = self::ACCOUNT_TYPE;
58
    }
59
60
    /**
61
     * Add a new address to the account.
62
     *
63
     * @param string $street     Street address.
64
     * @param string $number     Number address.
65
     * @param string $district   Neighborhood address.
66
     * @param string $city       City address.
67
     * @param string $state      State address.
68
     * @param string $zip        The zip code billing address.
69
     * @param string $complement Address complement.
70
     * @param string $country    Country ISO-alpha3 format, BRA example.
71
     *
72
     * @return $this
73
     */
74 View Code Duplication
    public function addAddress($street, $number, $district, $city, $state, $zip, $complement = null, $country = self::ADDRESS_COUNTRY)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        $address = new stdClass();
77
        $address->street = $street;
78
        $address->streetNumber = $number;
79
        $address->complement = $complement;
80
        $address->district = $district;
81
        $address->city = $city;
82
        $address->state = $state;
83
        $address->country = $country;
84
        $address->zipCode = $zip;
85
86
        $this->data->person->address = $address;
87
88
        return $this;
89
    }
90
91
    /**
92
     * Add alternative phone to an account.
93
     *
94
     * @param int $areaCode    DDD telephone.
95
     * @param int $number      Telephone number.
96
     * @param int $countryCode Country code.
97
     *
98
     * @return \Moip\Resource\Account
99
     */
100
    public function addAlternativePhone($areaCode, $number, $countryCode = 55)
101
    {
102
        $alternativePhone = new stdClass();
103
        $alternativePhone->countryCode = $countryCode;
104
        $alternativePhone->areaCode = $areaCode;
105
        $alternativePhone->number = $number;
106
107
        $this->data->person->alternativePhones[] = $alternativePhone;
108
109
        return $this;
110
    }
111
112
    /**
113
     * Create a new account.
114
     *
115
     * @return \stdClass
116
     */
117
    public function create()
118
    {
119
        return $this->createResource(sprintf('/%s/%s/', MoipResource::VERSION, self::PATH));
120
    }
121
122
    /**
123
     * Find a account.
124
     *
125
     * @param string $moip_id
126
     *
127
     * @return stdClass
128
     */
129
    public function get($moip_id)
130
    {
131
        return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::PATH, $moip_id));
132
    }
133
134
    /**
135
     * Check if an account exists.
136
     *
137
     * @param string $tax_document
138
     *
139
     * @return bool
140
     */
141
    public function checkExistence($tax_document)
142
    {
143
        try {
144
            $this->getByPathNoPopulate(sprintf('/%s/%s/%s?tax_document=%s', MoipResource::VERSION, self::PATH, 'exists', $tax_document));
145
146
            return true;
147
        } catch (ValidationException $e) {
148
            if ($e->getStatusCode() != 404) {
149
                throw new ValidationException($e->getStatusCode(), $e->getErrors());
150
            }
151
        }
152
153
        return false;
154
    }
155
156
    /**
157
     * Get account id.
158
     *
159
     * @return string The buyer id.
160
     */
161
    public function getId()
162
    {
163
        return $this->getIfSet('id');
164
    }
165
166
    /**
167
     * Get account access token.
168
     *
169
     * @return string
170
     */
171
    public function getAccessToken()
172
    {
173
        return $this->getIfSet('accessToken');
174
    }
175
176
    /**
177
     * Get account channel ID.
178
     *
179
     * @return string
180
     */
181
    public function getChannelId()
182
    {
183
        return $this->getIfSet('channelId');
184
    }
185
186
    /**
187
     * Get account login.
188
     *
189
     * @return string The buyer login.
190
     */
191
    public function getLogin()
192
    {
193
        return $this->getIfSet('login');
194
    }
195
196
    /**
197
     * Get account address.
198
     *
199
     * @return \stdClass Account's address.
200
     */
201
    public function getAddress()
202
    {
203
        return $this->getIfSet('address', $this->data->person);
204
    }
205
206
    /**
207
     * Get account fullname.
208
     *
209
     * @return string Account's full name.
210
     */
211
    public function getFullname()
212
    {
213
        return $this->getIfSet('name', $this->data->person).' '.$this->getIfSet('lastName', $this->data->person);
214
    }
215
216
    /**
217
     * Get birth date from account.
218
     *
219
     * @return \DateTime|null Date of birth of the credit card holder.
220
     */
221
    public function getBirthDate()
222
    {
223
        return $this->getIfSetDate('birthDate', $this->data->person);
224
    }
225
226
    /**
227
     * Get phone area code from account.
228
     *
229
     * @return int DDD telephone.
230
     */
231
    public function getPhoneAreaCode()
232
    {
233
        return $this->getIfSet('areaCode', $this->data->person->phone);
234
    }
235
236
    /**
237
     * Get phone country code from account.
238
     *
239
     * @return int Country code.
240
     */
241
    public function getPhoneCountryCode()
242
    {
243
        return $this->getIfSet('countryCode', $this->data->person->phone);
244
    }
245
246
    /**
247
     * Get phone number from account.
248
     *
249
     * @return int Telephone number.
250
     */
251
    public function getPhoneNumber()
252
    {
253
        return $this->getIfSet('number', $this->data->person->phone);
254
    }
255
256
    /**
257
     * Get tax document type from account.
258
     *
259
     * @return string Type of value: CPF and CNPJ
260
     */
261
    public function getTaxDocumentType()
262
    {
263
        return $this->getIfSet('type', $this->data->person->taxDocument);
264
    }
265
266
    /**
267
     * Get tax document number from account.
268
     *
269
     * @return string Document Number.
270
     */
271
    public function getTaxDocumentNumber()
272
    {
273
        return $this->getIfSet('number', $this->data->person->taxDocument);
274
    }
275
276
    /**
277
     * Get identity document number from account.
278
     *
279
     * @return string
280
     */
281
    public function getIdentityDocumentNumber()
282
    {
283
        return $this->getIfSet('number', $this->data->person->identityDocument);
284
    }
285
286
    /**
287
     * Get identity document issuer from account.
288
     *
289
     * @return string
290
     */
291
    public function getIdentityDocumentIssuer()
292
    {
293
        return $this->getIfSet('issuer', $this->data->person->identityDocument);
294
    }
295
296
    /**
297
     * Get identity document issue date from account.
298
     *
299
     * @return \DateTime
300
     */
301
    public function getIdentityDocumentIssueDate()
302
    {
303
        return $this->getIfSet('issueDate', $this->data->person->identityDocument);
304
    }
305
306
    /**
307
     * Get identity document type from account.
308
     *
309
     * @return string Type of value: RG
310
     */
311
    public function getIdentityDocumentType()
312
    {
313
        return $this->getIfSet('type', $this->data->person->identityDocument);
314
    }
315
316
    /**
317
     * Get alternative phones.
318
     *
319
     * @return array
320
     */
321
    public function getAlternativePhones()
322
    {
323
        return $this->getIfSet('alternativePhones', $this->data->person);
324
    }
325
326
    /**
327
     * Get company data.
328
     *
329
     * @return array
330
     */
331
    public function getCompany()
332
    {
333
        return $this->getIfSet('company', $this->data);
334
    }
335
336
    /**
337
     * Get email address.
338
     *
339
     * @return string
340
     */
341
    public function getEmailAddress()
342
    {
343
        return $this->getIfSet('address', $this->data->email);
344
    }
345
346
    /**
347
     * Get email confirmed.
348
     *
349
     * @return bool
350
     */
351
    public function getEmailConfirmed()
352
    {
353
        return $this->getIfSet('confirmed', $this->data->email);
354
    }
355
356
    /**
357
     * Get account type.
358
     *
359
     * @return string Document Number.
360
     */
361
    public function getType()
362
    {
363
        return $this->getIfSet('type', $this->data);
364
    }
365
366
    /**
367
     * Get transparent account (true/false).
368
     *
369
     * @return bool
370
     */
371
    public function getTransparentAccount()
372
    {
373
        return $this->getIfSet('transparentAccount', $this->data);
374
    }
375
376
    /**
377
     * Get account created at.
378
     *
379
     * @return string
380
     */
381
    public function getCreatedAt()
382
    {
383
        return $this->getIfSet('createdAt', $this->data);
384
    }
385
386
    /**
387
     * Mount the seller structure from account.
388
     *
389
     * @param \stdClass $response
390
     *
391
     * @return \Moip\Resource\Account Account data
392
     */
393
    protected function populate(stdClass $response)
394
    {
395
        $account = clone $this;
396
        $account->data->email = new stdClass();
397
398
        $email = $this->getIfSet('email', $response);
399
400
        $account->data->email->address = $this->getIfSet('address', $email);
401
        $account->data->email->confirmed = $this->getIfSet('confirmed', $email);
402
403
        $account->data->login = $this->getIfSet('login', $response);
404
        $account->data->person = new stdClass();
405
406
        $person = $this->getIfSet('person', $response);
407
408
        $account->data->person->name = $this->getIfSet('name', $person);
409
        $account->data->person->lastName = $this->getIfSet('lastName', $person);
410
        $account->data->person->taxDocument = new stdClass();
411
412
        $taxDocument = $this->getIfSet('taxDocument', $person);
413
414
        $account->data->person->taxDocument->type = $this->getIfSet('type', $taxDocument);
415
        $account->data->person->taxDocument->number = $this->getIfSet('number', $taxDocument);
416
        $account->data->person->phone = new stdClass();
417
418
        $phone = $this->getIfSet('phone', $person);
419
420
        $account->data->person->phone->countryCode = $this->getIfSet('countryCode', $phone);
421
        $account->data->person->phone->areaCode = $this->getIfSet('areaCode', $phone);
422
        $account->data->person->phone->number = $this->getIfSet('number', $phone);
423
        $account->data->person->identityDocument = new stdClass();
424
425
        $identityDocument = $this->getIfSet('identityDocument', $person);
426
427
        $account->data->person->identityDocument->type = $this->getIfSet('type', $identityDocument);
428
        $account->data->person->identityDocument->number = $this->getIfSet('number', $identityDocument);
429
        $account->data->person->identityDocument->issuer = $this->getIfSet('issuer', $identityDocument);
430
        $account->data->person->identityDocument->issueDate = $this->getIfSet('issueDate', $identityDocument);
431
432
        $account->data->person->birthDate = $this->getIfSet('birthDate', $person);
433
        $account->data->person->address = $this->getIfSet('address', $person);
434
435
        $account->data->person->alternativePhones = $this->getIfSet('alternativePhones', $person);
436
437
        $account->data->company = $this->getIfSet('company', $response);
438
        $account->data->_links = $this->getIfSet('_links', $response);
439
        $account->data->type = $this->getIfSet('type', $response);
440
        $account->data->id = $this->getIfSet('id', $response);
441
        $account->data->accessToken = $this->getIfSet('accessToken', $response);
442
        $account->data->channelId = $this->getIfSet('channelId', $response);
443
        $account->data->transparentAccount = $this->getIfSet('transparentAccount', $response);
444
        $account->data->createdAt = $this->getIfSet('createdAt', $response);
445
446
        return $account;
447
    }
448
449
    /**
450
     * Set e-mail from account.
451
     *
452
     * @param string $email Email account.
453
     *
454
     * @return \Moip\Resource\Account
455
     */
456
    public function setEmail($email)
457
    {
458
        $this->data->email->address = $email;
459
460
        return $this;
461
    }
462
463
    /**
464
     * Set name from account.
465
     *
466
     * @param string $name Account's person name.
467
     *
468
     * @return \Moip\Resource\Account
469
     */
470
    public function setName($name)
471
    {
472
        $this->data->person->name = $name;
473
474
        return $this;
475
    }
476
477
    /**
478
     * Set name from account.
479
     *
480
     * @param string $lastname Account's person name.
481
     *
482
     * @return \Moip\Resource\Account
483
     */
484
    public function setLastName($lastname)
485
    {
486
        $this->data->person->lastName = $lastname;
487
488
        return $this;
489
    }
490
491
    /**
492
     * Set birth date from account.
493
     *
494
     * @param \DateTime|string $birthDate Date of birth of the credit card holder.
495
     *
496
     * @return \Moip\Resource\Account
497
     */
498 View Code Duplication
    public function setBirthDate($birthDate)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
499
    {
500
        if ($birthDate instanceof \DateTime) {
501
            $birthDate = $birthDate->format('Y-m-d');
502
        }
503
504
        $this->data->person->birthDate = $birthDate;
505
506
        return $this;
507
    }
508
509
    /**
510
     * Set tax document from account.
511
     *
512
     * @param string $number Document number.
513
     * @param string $type   Document type.
514
     *
515
     * @return \Moip\Resource\Account
516
     */
517 View Code Duplication
    public function setTaxDocument($number, $type = self::TAX_DOCUMENT)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
518
    {
519
        $this->data->person->taxDocument = new stdClass();
520
        $this->data->person->taxDocument->type = $type;
521
        $this->data->person->taxDocument->number = $number;
522
523
        return $this;
524
    }
525
526
    /**
527
     * Set phone from account.
528
     *
529
     * @param int $areaCode    DDD telephone.
530
     * @param int $number      Telephone number.
531
     * @param int $countryCode Country code.
532
     *
533
     * @return \Moip\Resource\Account
534
     */
535 View Code Duplication
    public function setPhone($areaCode, $number, $countryCode = 55)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
536
    {
537
        $this->data->person->phone = new stdClass();
538
        $this->data->person->phone->countryCode = $countryCode;
539
        $this->data->person->phone->areaCode = $areaCode;
540
        $this->data->person->phone->number = $number;
541
542
        return $this;
543
    }
544
545
    /**
546
     * Set identity document from account.
547
     *
548
     * @param string $number Número do documento.
549
     * @param string $issuer Emissor do documento.
550
     * @param $issueDate
551
     * @param string $type Tipo do documento. Valores possíveis: RG.
552
     *
553
     * @return Account
554
     */
555
    public function setIdentityDocument($number, $issuer, $issueDate, $type = 'RG')
556
    {
557
        $this->data->person->identityDocument = new stdClass();
558
        $this->data->person->identityDocument->type = $type;
559
        $this->data->person->identityDocument->number = $number;
560
        $this->data->person->identityDocument->issuer = $issuer;
561
        $this->data->person->identityDocument->issueDate = $issueDate;
562
563
        return $this;
564
    }
565
566
    /**
567
     * Set person nationality.
568
     *
569
     * @param string $nationality Abbreviation for nationality (3 max length).
570
     *
571
     * @return $this
572
     */
573
    public function setNationality($nationality = self::ADDRESS_COUNTRY)
574
    {
575
        $this->data->person->nationality = $nationality;
576
577
        return $this;
578
    }
579
580
    /**
581
     * Set person birth place.
582
     *
583
     * @param string $birthPlace Birth place (city).
584
     *
585
     * @return $this
586
     */
587
    public function setBirthPlace($birthPlace)
588
    {
589
        $this->data->person->birthPlace = $birthPlace;
590
591
        return $this;
592
    }
593
594
    /**
595
     * Set parents name.
596
     *
597
     * @param string $motherName Mother name.
598
     * @param string $fatherName Father name.
599
     *
600
     * @return $this
601
     */
602
    public function setParentsName($motherName, $fatherName)
603
    {
604
        $this->data->person->parentsName = new stdClass();
605
        $this->data->person->parentsName->mother = $motherName;
606
        $this->data->person->parentsName->father = $fatherName;
607
608
        return $this;
609
    }
610
611
    /**
612
     * Set site.
613
     *
614
     * @param string $site URL from site.
615
     *
616
     * @return $this
617
     */
618
    public function setSite($site)
619
    {
620
        $this->data->site = $site;
621
622
        return $this;
623
    }
624
625
    /**
626
     * Set transparent account.
627
     *
628
     * @param bool $transparentAccount Set true if you want create a transparent account.
629
     *
630
     * @return $this
631
     */
632
    public function setTransparentAccount($transparentAccount)
633
    {
634
        $this->data->transparentAccount = $transparentAccount;
635
636
        return $this;
637
    }
638
639
    /**
640
     * Set business segment.
641
     *
642
     * @param int $segmentId business segment id. Possible values available at: https://documentao-moip.readme.io/v2.0/reference#tabela-de-categorias-de-estabelecimento .
643
     *
644
     * @return $this
645
     */
646
    public function setBusinessSegment($segmentId)
647
    {
648
        $this->data->businessSegment->id = $segmentId;
649
650
        return $this;
651
    }
652
653
    /**
654
     * Set company name.
655
     *
656
     * @param string $name         Trading Name.
657
     * @param string $businessName Company Name.
658
     *
659
     * @return $this
660
     */
661
    public function setCompanyName($name, $businessName)
662
    {
663
        $this->initializeCompany();
664
        $this->data->company->name = $name;
665
        $this->data->company->businessName = $businessName;
666
667
        return $this;
668
    }
669
670
    /**
671
     * Initialize company node.
672
     */
673
    private function initializeCompany()
674
    {
675
        if (!isset($this->data->company)) {
676
            $this->data->company = new stdClass();
677
        }
678
    }
679
680
    /**
681
     * Set company opening date.
682
     *
683
     * @param \DateTime|string $openingDate .
684
     *
685
     * @return $this
686
     */
687
    public function setCompanyOpeningDate($openingDate)
688
    {
689
        if ($openingDate instanceof \DateTime) {
690
            $openingDate = $openingDate->format('Y-m-d');
691
        }
692
        $this->initializeCompany();
693
        $this->data->company->openingDate = $openingDate;
694
695
        return $this;
696
    }
697
698
    /**
699
     * Set company tax document.
700
     *
701
     * @param string $documentNumber .
702
     *
703
     * @return $this
704
     */
705 View Code Duplication
    public function setCompanyTaxDocument($documentNumber)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
706
    {
707
        $this->initializeCompany();
708
        $this->data->company->taxDocument = new stdClass();
709
        $this->data->company->taxDocument->type = self::COMPANY_TAX_DOCUMENT;
710
        $this->data->company->taxDocument->number = $documentNumber;
711
712
        return $this;
713
    }
714
715
    /**
716
     * Set company tax document.
717
     *
718
     * @param string $documentNumber .
0 ignored issues
show
Bug introduced by
There is no parameter named $documentNumber. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
719
     *
720
     * @return $this
721
     */
722
    public function setCompanyMainActivity($cnae, $description)
723
    {
724
        $this->initializeCompany();
725
        $this->data->company->mainActivity = new stdClass();
726
        $this->data->company->mainActivity->cnae = $cnae;
727
        $this->data->company->mainActivity->description = $description;
728
729
        return $this;
730
    }
731
732
    /**
733
     * Set address to company.
734
     *
735
     * @param string $street     Street address.
736
     * @param string $number     Number address.
737
     * @param string $district   Neighborhood address.
738
     * @param string $city       City address.
739
     * @param string $state      State address.
740
     * @param string $zip        The zip code billing address.
741
     * @param string $complement Address complement.
742
     * @param string $country    Country ISO-alpha3 format, BRA example.
743
     *
744
     * @return $this
745
     */
746 View Code Duplication
    public function setCompanyAddress($street, $number, $district, $city, $state, $zip, $complement = null, $country = self::ADDRESS_COUNTRY)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
747
    {
748
        $address = new stdClass();
749
        $address->street = $street;
750
        $address->streetNumber = $number;
751
        $address->complement = $complement;
752
        $address->district = $district;
753
        $address->city = $city;
754
        $address->state = $state;
755
        $address->country = $country;
756
        $address->zipCode = $zip;
757
758
        $this->initializeCompany();
759
        $this->data->company->address = $address;
760
761
        return $this;
762
    }
763
764
    /**
765
     * Set company phone.
766
     *
767
     * @param int $areaCode    DDD telephone.
768
     * @param int $number      Telephone number.
769
     * @param int $countryCode Country code.
770
     *
771
     * @return \Moip\Resource\Account
772
     */
773
    public function setCompanyPhone($areaCode, $number, $countryCode = 55)
774
    {
775
        $this->initializeCompany();
776
        $this->data->company->phone = new stdClass();
777
        $this->data->company->phone->countryCode = $countryCode;
778
        $this->data->company->phone->areaCode = $areaCode;
779
        $this->data->company->phone->number = $number;
780
781
        return $this;
782
    }
783
784
    /**
785
     * Set account type. Possible values: CONSUMER, MERCHANT.
786
     *
787
     * @param string $type
788
     *
789
     * @return \Moip\Resource\Account
790
     */
791
    public function setType($type)
792
    {
793
        $this->data->type = $type;
794
795
        return $this;
796
    }
797
}
798