Skip to content

Commit

Permalink
fix(Transfers): Fix setHolder warning when called before setTransfers (
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleyton Basilio Pilon committed Oct 3, 2017
1 parent c860b75 commit 33f9126
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Resource/Transfers.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ protected function populate(stdClass $response)
return $transfers;
}

/**
* Initializes new transferInstrument instance if it doesn't exist
*/
private function intializeTransferInstrument()
{
if (!isset($this->data->transferInstrument)) {
$this->data->transferInstrument = new stdClass();
}
}

/**
* Set info of transfers.
*
Expand All @@ -71,7 +81,7 @@ public function setTransfers(
$accountCheckNumber
) {
$this->data->amount = $amount;
$this->data->transferInstrument = new stdClass();
$this->intializeTransferInstrument();
$this->data->transferInstrument->method = self::METHOD;
$this->data->transferInstrument->bankAccount = new stdClass();
$this->data->transferInstrument->bankAccount->type = self::TYPE;
Expand All @@ -92,6 +102,7 @@ public function setTransfers(
*/
public function setHolder($fullname, $taxDocument)
{
$this->intializeTransferInstrument();
$this->data->transferInstrument->bankAccount->holder = new stdClass();
$this->data->transferInstrument->bankAccount->holder->fullname = $fullname;
$this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass();
Expand Down

0 comments on commit 33f9126

Please sign in to comment.