Account   F
last analyzed

Complexity

Total Complexity 60

Size/Duplication

Total Lines 841
Duplicated Lines 9.51 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 60
c 1
b 1
f 0
lcom 1
cbo 2
dl 80
loc 841
rs 1.9999

55 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 9 1
A addAddress() 16 16 1
A addAlternativePhone() 0 11 1
A create() 0 4 1
A get() 0 4 1
A checkExistence() 0 14 3
A getId() 0 4 1
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 getBusinessSegmentId() 0 4 1
A getBusinessSegmentName() 0 4 1
A getBusinessSegmentMcc() 0 4 1
A getTransparentAccount() 0 4 1
A getCreatedAt() 0 4 1
A getPasswordLink() 0 4 1
A populate() 0 68 1
A setEmail() 0 6 1
A setName() 0 6 1
A setLastName() 0 6 1
A setBirthDate() 10 10 2
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 setCompanyAddress() 17 17 1
A setType() 0 6 1
A setTaxDocument() 0 8 1
A setCompanyMainActivity() 9 9 1
A setCompanyPhone() 10 10 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->businessSegment = new stdClass();
58
        $this->data->type = self::ACCOUNT_TYPE;
59
    }
60
61
    /**
62
     * Add a new address to the account.
63
     *
64
     * @param string $street     Street address.
65
     * @param string $number     Number address.
66
     * @param string $district   Neighborhood address.
67
     * @param string $city       City address.
68
     * @param string $state      State address.
69
     * @param string $zip        The zip code billing address.
70
     * @param string $complement Address complement.
71
     * @param string $country    Country ISO-alpha3 format, BRA example.
72
     *
73
     * @return $this
74
     */
75 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...
76
    {
77
        $address = new stdClass();
78
        $address->street = $street;
79
        $address->streetNumber = $number;
80
        $address->complement = $complement;
81
        $address->district = $district;
82
        $address->city = $city;
83
        $address->state = $state;
84
        $address->country = $country;
85
        $address->zipCode = $zip;
86
87
        $this->data->person->address = $address;
88
89
        return $this;
90
    }
91
92
    /**
93
     * Add alternative phone to an account.
94
     *
95
     * @param int $areaCode    DDD telephone.
96
     * @param int $number      Telephone number.
97
     * @param int $countryCode Country code.
98
     *
99
     * @return \Moip\Resource\Account
100
     */
101
    public function addAlternativePhone($areaCode, $number, $countryCode = 55)
102
    {
103
        $alternativePhone = new stdClass();
104
        $alternativePhone->countryCode = $countryCode;
105
        $alternativePhone->areaCode = $areaCode;
106
        $alternativePhone->number = $number;
107
108
        $this->data->person->alternativePhones[] = $alternativePhone;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Create a new account.
115
     *
116
     * @return \stdClass
117
     */
118
    public function create()
119
    {
120
        return $this->createResource(sprintf('/%s/%s/', MoipResource::VERSION, self::PATH));
121
    }
122
123
    /**
124
     * Find a account.
125
     *
126
     * @param string $moip_id
127
     *
128
     * @return stdClass
129
     */
130
    public function get($moip_id)
131
    {
132
        return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::PATH, $moip_id));
133
    }
134
135
    /**
136
     * Check if an account exists.
137
     *
138
     * @param string $tax_document
139
     *
140
     * @return bool
141
     */
142
    public function checkExistence($tax_document)
143
    {
144
        try {
145
            $this->getByPathNoPopulate(sprintf('/%s/%s/%s?tax_document=%s', MoipResource::VERSION, self::PATH, 'exists', $tax_document));
146
147
            return true;
148
        } catch (ValidationException $e) {
149
            if ($e->getStatusCode() != 404) {
150
                throw new ValidationException($e->getStatusCode(), $e->getErrors());
151
            }
152
        }
153
154
        return false;
155
    }
156
157
    /**
158
     * Get account id.
159
     *
160
     * @return string The buyer id.
161
     */
162
    public function getId()
163
    {
164
        return $this->getIfSet('id');
165
    }
166
167
    /**
168
     * Get account access token.
169
     *
170
     * @return string
171
     */
172
    public function getAccessToken()
173
    {
174
        return $this->getIfSet('accessToken');
175
    }
176
177
    /**
178
     * Get account channel ID.
179
     *
180
     * @return string
181
     */
182
    public function getChannelId()
183
    {
184
        return $this->getIfSet('channelId');
185
    }
186
187
    /**
188
     * Get account login.
189
     *
190
     * @return string The buyer login.
191
     */
192
    public function getLogin()
193
    {
194
        return $this->getIfSet('login');
195
    }
196
197
    /**
198
     * Get account address.
199
     *
200
     * @return \stdClass Account's address.
201
     */
202
    public function getAddress()
203
    {
204
        return $this->getIfSet('address', $this->data->person);
205
    }
206
207
    /**
208
     * Get account fullname.
209
     *
210
     * @return string Account's full name.
211
     */
212
    public function getFullname()
213
    {
214
        return $this->getIfSet('name', $this->data->person).' '.$this->getIfSet('lastName', $this->data->person);
215
    }
216
217
    /**
218
     * Get birth date from account.
219
     *
220
     * @return \DateTime|null Date of birth of the credit card holder.
221
     */
222
    public function getBirthDate()
223
    {
224
        return $this->getIfSetDate('birthDate', $this->data->person);
225
    }
226
227
    /**
228
     * Get phone area code from account.
229
     *
230
     * @return int DDD telephone.
231
     */
232
    public function getPhoneAreaCode()
233
    {
234
        return $this->getIfSet('areaCode', $this->data->person->phone);
235
    }
236
237
    /**
238
     * Get phone country code from account.
239
     *
240
     * @return int Country code.
241
     */
242
    public function getPhoneCountryCode()
243
    {
244
        return $this->getIfSet('countryCode', $this->data->person->phone);
245
    }
246
247
    /**
248
     * Get phone number from account.
249
     *
250
     * @return int Telephone number.
251
     */
252
    public function getPhoneNumber()
253
    {
254
        return $this->getIfSet('number', $this->data->person->phone);
255
    }
256
257
    /**
258
     * Get tax document type from account.
259
     *
260
     * @return string Type of value: CPF and CNPJ
261
     */
262
    public function getTaxDocumentType()
263
    {
264
        return $this->getIfSet('type', $this->data->person->taxDocument);
265
    }
266
267
    /**
268
     * Get tax document number from account.
269
     *
270
     * @return string Document Number.
271
     */
272
    public function getTaxDocumentNumber()
273
    {
274
        return $this->getIfSet('number', $this->data->person->taxDocument);
275
    }
276
277
    /**
278
     * Get identity document number from account.
279
     *
280
     * @return string
281
     */
282
    public function getIdentityDocumentNumber()
283
    {
284
        return $this->getIfSet('number', $this->data->person->identityDocument);
285
    }
286
287
    /**
288
     * Get identity document issuer from account.
289
     *
290
     * @return string
291
     */
292
    public function getIdentityDocumentIssuer()
293
    {
294
        return $this->getIfSet('issuer', $this->data->person->identityDocument);
295
    }
296
297
    /**
298
     * Get identity document issue date from account.
299
     *
300
     * @return \DateTime
301
     */
302
    public function getIdentityDocumentIssueDate()
303
    {
304
        return $this->getIfSet('issueDate', $this->data->person->identityDocument);
305
    }
306
307
    /**
308
     * Get identity document type from account.
309
     *
310
     * @return string Type of value: RG
311
     */
312
    public function getIdentityDocumentType()
313
    {
314
        return $this->getIfSet('type', $this->data->person->identityDocument);
315
    }
316
317
    /**
318
     * Get alternative phones.
319
     *
320
     * @return array
321
     */
322
    public function getAlternativePhones()
323
    {
324
        return $this->getIfSet('alternativePhones', $this->data->person);
325
    }
326
327
    /**
328
     * Get company data.
329
     *
330
     * @return array
331
     */
332
    public function getCompany()
333
    {
334
        return $this->getIfSet('company', $this->data);
335
    }
336
337
    /**
338
     * Get email address.
339
     *
340
     * @return string
341
     */
342
    public function getEmailAddress()
343
    {
344
        return $this->getIfSet('address', $this->data->email);
345
    }
346
347
    /**
348
     * Get email confirmed.
349
     *
350
     * @return bool
351
     */
352
    public function getEmailConfirmed()
353
    {
354
        return $this->getIfSet('confirmed', $this->data->email);
355
    }
356
357
    /**
358
     * Get account type.
359
     *
360
     * @return string Document Number.
361
     */
362
    public function getType()
363
    {
364
        return $this->getIfSet('type', $this->data);
365
    }
366
367
    /**
368
     * Get business segment id.
369
     *
370
     * @return int id.
371
     */
372
    public function getBusinessSegmentId()
373
    {
374
        return $this->getIfSet('id', $this->data->businessSegment);
375
    }
376
377
    /**
378
     * Get business segment name.
379
     *
380
     * @return string name.
381
     */
382
    public function getBusinessSegmentName()
383
    {
384
        return $this->getIfSet('name', $this->data->businessSegment);
385
    }
386
387
    /**
388
     * Get business segment mcc.
389
     *
390
     * @return int mcc.
391
     */
392
    public function getBusinessSegmentMcc()
393
    {
394
        return $this->getIfSet('mcc', $this->data->businessSegment);
395
    }
396
397
    /**
398
     * Get transparent account (true/false).
399
     *
400
     * @return bool
401
     */
402
    public function getTransparentAccount()
403
    {
404
        return $this->getIfSet('transparentAccount', $this->data);
405
    }
406
407
    /**
408
     * Get account created at.
409
     *
410
     * @return string
411
     */
412
    public function getCreatedAt()
413
    {
414
        return $this->getIfSet('createdAt', $this->data);
415
    }
416
417
    /**
418
     * Get link to set the password of created account.
419
     *
420
     * @return string
421
     */
422
    public function getPasswordLink()
423
    {
424
        return $this->getIfSet('href', $this->data->_links->setPassword);
425
    }
426
427
    /**
428
     * Mount the seller structure from account.
429
     *
430
     * @param \stdClass $response
431
     *
432
     * @return \Moip\Resource\Account Account data
433
     */
434
    protected function populate(stdClass $response)
435
    {
436
        $account = clone $this;
437
        $account->data->email = new stdClass();
438
439
        $email = $this->getIfSet('email', $response);
440
441
        $account->data->email->address = $this->getIfSet('address', $email);
442
        $account->data->email->confirmed = $this->getIfSet('confirmed', $email);
443
444
        $account->data->login = $this->getIfSet('login', $response);
445
        $account->data->person = new stdClass();
446
447
        $person = $this->getIfSet('person', $response);
448
449
        $account->data->person->name = $this->getIfSet('name', $person);
450
        $account->data->person->lastName = $this->getIfSet('lastName', $person);
451
        $account->data->person->taxDocument = new stdClass();
452
453
        $taxDocument = $this->getIfSet('taxDocument', $person);
454
455
        $account->data->person->taxDocument->type = $this->getIfSet('type', $taxDocument);
456
        $account->data->person->taxDocument->number = $this->getIfSet('number', $taxDocument);
457
        $account->data->person->phone = new stdClass();
458
459
        $phone = $this->getIfSet('phone', $person);
460
461
        $account->data->person->phone->countryCode = $this->getIfSet('countryCode', $phone);
462
        $account->data->person->phone->areaCode = $this->getIfSet('areaCode', $phone);
463
        $account->data->person->phone->number = $this->getIfSet('number', $phone);
464
        $account->data->person->identityDocument = new stdClass();
465
466
        $identityDocument = $this->getIfSet('identityDocument', $person);
467
468
        $account->data->person->identityDocument->type = $this->getIfSet('type', $identityDocument);
469
        $account->data->person->identityDocument->number = $this->getIfSet('number', $identityDocument);
470
        $account->data->person->identityDocument->issuer = $this->getIfSet('issuer', $identityDocument);
471
        $account->data->person->identityDocument->issueDate = $this->getIfSet('issueDate', $identityDocument);
472
473
        $account->data->person->birthDate = $this->getIfSet('birthDate', $person);
474
        $account->data->person->address = $this->getIfSet('address', $person);
475
476
        $account->data->person->alternativePhones = $this->getIfSet('alternativePhones', $person);
477
478
        $businessSegment = $this->getIfSet('businessSegment', $response);
479
480
        $account->data->businessSegment->id = $this->getIfSet('id', $businessSegment);
481
        $account->data->businessSegment->name = $this->getIfSet('name', $businessSegment);
482
        $account->data->businessSegment->mcc = $this->getIfSet('mcc', $businessSegment);
483
484
        $account->data->company = $this->getIfSet('company', $response);
485
        $account->data->_links = new stdClass();
486
487
        $_links = $this->getIfSet('_links', $response);
488
        $account->data->_links->setPassword = new stdClass();
489
490
        $setPassword = $this->getIfSet('setPassword', $_links);
491
        $account->data->_links->setPassword->href = $this->getIfSet('href', $setPassword);
492
493
        $account->data->type = $this->getIfSet('type', $response);
494
        $account->data->id = $this->getIfSet('id', $response);
495
        $account->data->accessToken = $this->getIfSet('accessToken', $response);
496
        $account->data->channelId = $this->getIfSet('channelId', $response);
497
        $account->data->transparentAccount = $this->getIfSet('transparentAccount', $response);
498
        $account->data->createdAt = $this->getIfSet('createdAt', $response);
499
500
        return $account;
501
    }
502
503
    /**
504
     * Set e-mail from account.
505
     *
506
     * @param string $email Email account.
507
     *
508
     * @return \Moip\Resource\Account
509
     */
510
    public function setEmail($email)
511
    {
512
        $this->data->email->address = $email;
513
514
        return $this;
515
    }
516
517
    /**
518
     * Set name from account.
519
     *
520
     * @param string $name Account's person name.
521
     *
522
     * @return \Moip\Resource\Account
523
     */
524
    public function setName($name)
525
    {
526
        $this->data->person->name = $name;
527
528
        return $this;
529
    }
530
531
    /**
532
     * Set name from account.
533
     *
534
     * @param string $lastname Account's person name.
535
     *
536
     * @return \Moip\Resource\Account
537
     */
538
    public function setLastName($lastname)
539
    {
540
        $this->data->person->lastName = $lastname;
541
542
        return $this;
543
    }
544
545
    /**
546
     * Set birth date from account.
547
     *
548
     * @param \DateTime|string $birthDate Date of birth of the credit card holder.
549
     *
550
     * @return \Moip\Resource\Account
551
     */
552 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...
553
    {
554
        if ($birthDate instanceof \DateTime) {
555
            $birthDate = $birthDate->format('Y-m-d');
556
        }
557
558
        $this->data->person->birthDate = $birthDate;
559
560
        return $this;
561
    }
562
563
    /**
564
     * Set tax document from account.
565
     *
566
     * @param string $number Document number.
567
     * @param string $type   Document type.
568
     *
569
     * @return \Moip\Resource\Account
570
     */
571
    public function setTaxDocument($number, $type = self::TAX_DOCUMENT)
572
    {
573
        $this->data->person->taxDocument = new stdClass();
574
        $this->data->person->taxDocument->type = $type;
575
        $this->data->person->taxDocument->number = $number;
576
577
        return $this;
578
    }
579
580
    /**
581
     * Set phone from account.
582
     *
583
     * @param int $areaCode    DDD telephone.
584
     * @param int $number      Telephone number.
585
     * @param int $countryCode Country code.
586
     *
587
     * @return \Moip\Resource\Account
588
     */
589 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...
590
    {
591
        $this->data->person->phone = new stdClass();
592
        $this->data->person->phone->countryCode = $countryCode;
593
        $this->data->person->phone->areaCode = $areaCode;
594
        $this->data->person->phone->number = $number;
595
596
        return $this;
597
    }
598
599
    /**
600
     * Set identity document from account.
601
     *
602
     * @param string $number Número do documento.
603
     * @param string $issuer Emissor do documento.
604
     * @param $issueDate
605
     * @param string $type Tipo do documento. Valores possíveis: RG.
606
     *
607
     * @return Account
608
     */
609
    public function setIdentityDocument($number, $issuer, $issueDate, $type = 'RG')
610
    {
611
        $this->data->person->identityDocument = new stdClass();
612
        $this->data->person->identityDocument->type = $type;
613
        $this->data->person->identityDocument->number = $number;
614
        $this->data->person->identityDocument->issuer = $issuer;
615
        $this->data->person->identityDocument->issueDate = $issueDate;
616
617
        return $this;
618
    }
619
620
    /**
621
     * Set person nationality.
622
     *
623
     * @param string $nationality Abbreviation for nationality (3 max length).
624
     *
625
     * @return $this
626
     */
627
    public function setNationality($nationality = self::ADDRESS_COUNTRY)
628
    {
629
        $this->data->person->nationality = $nationality;
630
631
        return $this;
632
    }
633
634
    /**
635
     * Set person birth place.
636
     *
637
     * @param string $birthPlace Birth place (city).
638
     *
639
     * @return $this
640
     */
641
    public function setBirthPlace($birthPlace)
642
    {
643
        $this->data->person->birthPlace = $birthPlace;
644
645
        return $this;
646
    }
647
648
    /**
649
     * Set parents name.
650
     *
651
     * @param string $motherName Mother name.
652
     * @param string $fatherName Father name.
653
     *
654
     * @return $this
655
     */
656
    public function setParentsName($motherName, $fatherName)
657
    {
658
        $this->data->person->parentsName = new stdClass();
659
        $this->data->person->parentsName->mother = $motherName;
660
        $this->data->person->parentsName->father = $fatherName;
661
662
        return $this;
663
    }
664
665
    /**
666
     * Set site.
667
     *
668
     * @param string $site URL from site.
669
     *
670
     * @return $this
671
     */
672
    public function setSite($site)
673
    {
674
        $this->data->site = $site;
675
676
        return $this;
677
    }
678
679
    /**
680
     * Set transparent account.
681
     *
682
     * @param bool $transparentAccount Set true if you want create a transparent account.
683
     *
684
     * @return $this
685
     */
686
    public function setTransparentAccount($transparentAccount)
687
    {
688
        $this->data->transparentAccount = $transparentAccount;
689
690
        return $this;
691
    }
692
693
    /**
694
     * Set business segment.
695
     *
696
     * @param int $segmentId business segment id. Possible values available at: https://documentao-moip.readme.io/v2.0/reference#tabela-de-categorias-de-estabelecimento .
697
     *
698
     * @return $this
699
     */
700
    public function setBusinessSegment($segmentId)
701
    {
702
        $this->data->businessSegment->id = $segmentId;
703
704
        return $this;
705
    }
706
707
    /**
708
     * Set company name.
709
     *
710
     * @param string $name         Trading Name.
711
     * @param string $businessName Company Name.
712
     *
713
     * @return $this
714
     */
715
    public function setCompanyName($name, $businessName)
716
    {
717
        $this->initializeCompany();
718
        $this->data->company->name = $name;
719
        $this->data->company->businessName = $businessName;
720
721
        return $this;
722
    }
723
724
    /**
725
     * Initialize company node.
726
     */
727
    private function initializeCompany()
728
    {
729
        if (!isset($this->data->company)) {
730
            $this->data->company = new stdClass();
731
        }
732
    }
733
734
    /**
735
     * Set company opening date.
736
     *
737
     * @param \DateTime|string $openingDate .
738
     *
739
     * @return $this
740
     */
741
    public function setCompanyOpeningDate($openingDate)
742
    {
743
        if ($openingDate instanceof \DateTime) {
744
            $openingDate = $openingDate->format('Y-m-d');
745
        }
746
        $this->initializeCompany();
747
        $this->data->company->openingDate = $openingDate;
748
749
        return $this;
750
    }
751
752
    /**
753
     * Set company tax document.
754
     *
755
     * @param string $documentNumber .
756
     *
757
     * @return $this
758
     */
759 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...
760
    {
761
        $this->initializeCompany();
762
        $this->data->company->taxDocument = new stdClass();
763
        $this->data->company->taxDocument->type = self::COMPANY_TAX_DOCUMENT;
764
        $this->data->company->taxDocument->number = $documentNumber;
765
766
        return $this;
767
    }
768
769
    /**
770
     * Set company tax document.
771
     *
772
     * @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...
773
     *
774
     * @return $this
775
     */
776 View Code Duplication
    public function setCompanyMainActivity($cnae, $description)
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...
777
    {
778
        $this->initializeCompany();
779
        $this->data->company->mainActivity = new stdClass();
780
        $this->data->company->mainActivity->cnae = $cnae;
781
        $this->data->company->mainActivity->description = $description;
782
783
        return $this;
784
    }
785
786
    /**
787
     * Set address to company.
788
     *
789
     * @param string $street     Street address.
790
     * @param string $number     Number address.
791
     * @param string $district   Neighborhood address.
792
     * @param string $city       City address.
793
     * @param string $state      State address.
794
     * @param string $zip        The zip code billing address.
795
     * @param string $complement Address complement.
796
     * @param string $country    Country ISO-alpha3 format, BRA example.
797
     *
798
     * @return $this
799
     */
800 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...
801
    {
802
        $address = new stdClass();
803
        $address->street = $street;
804
        $address->streetNumber = $number;
805
        $address->complement = $complement;
806
        $address->district = $district;
807
        $address->city = $city;
808
        $address->state = $state;
809
        $address->country = $country;
810
        $address->zipCode = $zip;
811
812
        $this->initializeCompany();
813
        $this->data->company->address = $address;
814
815
        return $this;
816
    }
817
818
    /**
819
     * Set company phone.
820
     *
821
     * @param int $areaCode    DDD telephone.
822
     * @param int $number      Telephone number.
823
     * @param int $countryCode Country code.
824
     *
825
     * @return \Moip\Resource\Account
826
     */
827 View Code Duplication
    public function setCompanyPhone($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...
828
    {
829
        $this->initializeCompany();
830
        $this->data->company->phone = new stdClass();
831
        $this->data->company->phone->countryCode = $countryCode;
832
        $this->data->company->phone->areaCode = $areaCode;
833
        $this->data->company->phone->number = $number;
834
835
        return $this;
836
    }
837
838
    /**
839
     * Set account type. Possible values: CONSUMER, MERCHANT.
840
     *
841
     * @param string $type
842
     *
843
     * @return \Moip\Resource\Account
844
     */
845
    public function setType($type)
846
    {
847
        $this->data->type = $type;
848
849
        return $this;
850
    }
851
}
852