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

Commit

Permalink
Fixed illegal string offset error in getXmlObjectFieldAttribute metho…
Browse files Browse the repository at this point in the history
…ds, which occured in PHP 5.6
  • Loading branch information
stevenobird authored and devheidelpay committed Apr 28, 2017
1 parent 392742b commit acec8ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function __construct($xmlResponse = null)
*
* @param string $response
*/
public function setRawResponse(string $response)
public function setRawResponse($response)
{
$this->xmlResponse = $response;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/PushMapping/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ public function getXmlObjectFieldAttribute(\SimpleXMLElement $xmlElement, $field
{
list($field, $attribute) = explode(':', $fieldAttribute);

if (isset($xmlElement->Transaction->Account->$field[$attribute])) {
return (string)$xmlElement->Transaction->Account->$field[$attribute];
if (isset($xmlElement->Transaction->Account->$field)) {
if (isset($xmlElement->Transaction->Account->$field->attributes()->$attribute)) {
return (string)$xmlElement->Transaction->Account->$field->attributes()->$attribute;
}
}

return null;
Expand Down
16 changes: 5 additions & 11 deletions lib/PushMapping/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public function getXmlObjectFieldAttribute(\SimpleXMLElement $xmlElement, $field
{
list($field, $attribute) = explode(':', $fieldAttribute);

if (isset($xmlElement->Transaction->Processing->$field[$attribute])) {
return (string)$xmlElement->Transaction->Processing->$field[$attribute];
if (isset($xmlElement->Transaction->Processing->$field)) {
if (isset($xmlElement->Transaction->Processing->$field->attributes()->$attribute)) {
return (string)$xmlElement->Transaction->Processing->$field->attributes()->$attribute;
}
}

return null;
Expand All @@ -60,15 +62,7 @@ public function getXmlObjectFieldAttribute(\SimpleXMLElement $xmlElement, $field
public function getXmlObjectProperty(\SimpleXMLElement $xmlElement, $property)
{
if (isset($xmlElement->Transaction->Processing[$property])) {
$result = (string)$xmlElement->Transaction->Processing[$property];

// temporary solution: code in xml response contents too much, we cut it here.
if ($property == 'code') {
$codeRaw = explode('.', $result);
$result = $codeRaw[0] . '.' . $codeRaw[1];
}

return $result;
return (string)$xmlElement->Transaction->Processing[$property];
}

return null;
Expand Down

0 comments on commit acec8ba

Please sign in to comment.