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

Commit 33f9126

Browse files
author
Kleyton Basilio Pilon
committed
fix(Transfers): Fix setHolder warning when called before setTransfers (#184).
1 parent c860b75 commit 33f9126

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Resource/Transfers.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ protected function populate(stdClass $response)
5050
return $transfers;
5151
}
5252

53+
/**
54+
* Initializes new transferInstrument instance if it doesn't exist
55+
*/
56+
private function intializeTransferInstrument()
57+
{
58+
if (!isset($this->data->transferInstrument)) {
59+
$this->data->transferInstrument = new stdClass();
60+
}
61+
}
62+
5363
/**
5464
* Set info of transfers.
5565
*
@@ -71,7 +81,7 @@ public function setTransfers(
7181
$accountCheckNumber
7282
) {
7383
$this->data->amount = $amount;
74-
$this->data->transferInstrument = new stdClass();
84+
$this->intializeTransferInstrument();
7585
$this->data->transferInstrument->method = self::METHOD;
7686
$this->data->transferInstrument->bankAccount = new stdClass();
7787
$this->data->transferInstrument->bankAccount->type = self::TYPE;
@@ -92,6 +102,7 @@ public function setTransfers(
92102
*/
93103
public function setHolder($fullname, $taxDocument)
94104
{
105+
$this->intializeTransferInstrument();
95106
$this->data->transferInstrument->bankAccount->holder = new stdClass();
96107
$this->data->transferInstrument->bankAccount->holder->fullname = $fullname;
97108
$this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass();

0 commit comments

Comments
 (0)