Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit a6e992f

Browse files
author
Kleyton Basilio Pilon
committed
fix(Transfers): Improved fix to issue #184
1 parent 7ab6900 commit a6e992f

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/Resource/Transfers.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class Transfers extends MoipResource
3838
protected function initialize()
3939
{
4040
$this->data = new stdClass();
41+
$this->data->transferInstrument = new stdClass();
42+
$this->data->transferInstrument->bankAccount = new stdClass();
43+
$this->data->transferInstrument->bankAccount->holder = new stdClass();
44+
$this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass();
4145
}
4246

4347
/**
@@ -76,16 +80,6 @@ protected function populate(stdClass $response)
7680
return $transfers;
7781
}
7882

79-
/**
80-
* Initializes new transferInstrument instance if it doesn't exist.
81-
*/
82-
private function intializeTransferInstrument()
83-
{
84-
if (!isset($this->data->transferInstrument)) {
85-
$this->data->transferInstrument = new stdClass();
86-
}
87-
}
88-
8983
/**
9084
* Set info of transfers.
9185
*
@@ -107,9 +101,7 @@ public function setTransfers(
107101
$accountCheckNumber
108102
) {
109103
$this->data->amount = $amount;
110-
$this->intializeTransferInstrument();
111104
$this->data->transferInstrument->method = self::METHOD;
112-
$this->data->transferInstrument->bankAccount = new stdClass();
113105
$this->data->transferInstrument->bankAccount->type = self::TYPE;
114106
$this->data->transferInstrument->bankAccount->bankNumber = $bankNumber;
115107
$this->data->transferInstrument->bankAccount->agencyNumber = $agencyNumber;
@@ -140,10 +132,7 @@ public function getTransfers()
140132
*/
141133
public function setHolder($fullname, $taxDocument)
142134
{
143-
$this->intializeTransferInstrument();
144-
$this->data->transferInstrument->bankAccount->holder = new stdClass();
145135
$this->data->transferInstrument->bankAccount->holder->fullname = $fullname;
146-
$this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass();
147136
$this->data->transferInstrument->bankAccount->holder->taxDocument->type = self::TYPE_HOLD;
148137
$this->data->transferInstrument->bankAccount->holder->taxDocument->number = $taxDocument;
149138

0 commit comments

Comments
 (0)