Code Duplication    Length = 32-32 lines in 2 locations

Gateway/Request/TaxDocumentDataRequest.php 1 location

@@ 75-106 (lines=32) @@
72
     *
73
     * @return value
74
     */
75
    public function getValueForTaxDocument($orderAdapter)
76
    {
77
        $obtainTaxDocFrom = $this->config->getAddtionalValue('type_cpf');
78
79
        if ($obtainTaxDocFrom === 'customer') {
80
            $taxDocument = $orderAdapter->getCustomerTaxvat();
81
            $attTaxDocCus = $this->config->getAddtionalValue('cpf_for_customer');
82
83
            if ($attTaxDocCus !== 'taxvat') {
84
                $taxDocument = $orderAdapter->getData($attTaxDocCus);
85
            }
86
        } else {
87
            $taxDocument = $orderAdapter->getBillingAddress()->getVatId();
88
            $attTaxDocAddress = $this->config->getAddtionalValue('cpf_for_address');
89
90
            if ($attTaxDocAddress !== 'vat_id') {
91
                $taxDocument = $orderAdapter->getBillingAddress()->getData($attTaxDocAddress);
92
            }
93
        }
94
95
        // * Contigência para caso não haja o atributo informado pelo Admin busque me 2 outros campos comuns.
96
        if (!$taxDocument) {
97
            $taxDocument = $orderAdapter->getBillingAddress()->getVatId();
98
99
            $obtainTaxDocFrom = $this->config->getAddtionalValue('type_cpf');
100
            if ($obtainTaxDocFrom === 'customer') {
101
                $taxDocument = $orderAdapter->getCustomerTaxvat();
102
            }
103
        }
104
105
        return $taxDocument;
106
    }
107
108
    /**
109
     * {@inheritdoc}

Gateway/Request/PaymentDataRequest.php 1 location

@@ 399-430 (lines=32) @@
396
     *
397
     * @return value
398
     */
399
    public function getValueForTaxDocument($orderAdapter)
400
    {
401
        $obtainTaxDocFrom = $this->config->getAddtionalValue('type_cpf');
402
403
        if ($obtainTaxDocFrom === 'customer') {
404
            $taxDocument = $orderAdapter->getCustomerTaxvat();
405
            $attTaxDocCus = $this->config->getAddtionalValue('cpf_for_customer');
406
407
            if ($attTaxDocCus !== 'taxvat') {
408
                $taxDocument = $orderAdapter->getData($attTaxDocCus);
409
            }
410
        } else {
411
            $taxDocument = $orderAdapter->getBillingAddress()->getVatId();
412
            $attTaxDocAddress = $this->config->getAddtionalValue('cpf_for_address');
413
414
            if ($attTaxDocAddress !== 'vat_id') {
415
                $taxDocument = $orderAdapter->getBillingAddress()->getData($attTaxDocAddress);
416
            }
417
        }
418
419
        // * Contigência para caso não haja o atributo informado pelo Admin busque me 2 outros campos comuns.
420
        if (!$taxDocument) {
421
            $taxDocument = $orderAdapter->getBillingAddress()->getVatId();
422
423
            $obtainTaxDocFrom = $this->config->getAddtionalValue('type_cpf');
424
            if ($obtainTaxDocFrom === 'customer') {
425
                $taxDocument = $orderAdapter->getCustomerTaxvat();
426
            }
427
        }
428
429
        return $taxDocument;
430
    }
431
432
    /**
433
     * StructurePhone.