Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Extracts param appender and accounts for recursion
Browse files Browse the repository at this point in the history
Craig Paul committed Oct 26, 2016
1 parent 43f3c92 commit 57f7141
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/Transaction.php
Original file line number Diff line number Diff line change
@@ -72,6 +72,27 @@ public function amount()
return null;
}

/**
* Append elements to the XML response.
*
* @param array $params
* @param \SimpleXMLElement $type
*
* @return void
*/
protected function append(array $params, SimpleXMLElement $type)
{
foreach ($params as $key => $value) {
if (is_array($value)) {
$parent = $type->addChild($key);

$this->append($value, $parent);
} else {
$type->addChild($key, $value);
}
}
}

/**
* Check that the required parameters have not been provided to the transaction.
*
@@ -198,9 +219,7 @@ public function toXml()
}
}

foreach ($params as $key => $value) {
$type->addChild($key, $value);
}
$this->append($params, $type);

return $xml->asXML();
}

0 comments on commit 57f7141

Please sign in to comment.