Skip to content

Commit 1fe6f4e

Browse files
authored
Merge pull request #127 from dmgctrlr/master
Fix issues related to xml2Array in query functions See also issue #105 - the same problem on a different message. Perhaps this flags up refactoring needed to remove some duplicate code.
2 parents bd23ae4 + a9d460a commit 1fe6f4e

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

src/Message/Query/AbstractQueryResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ abstract class AbstractQueryResponse extends AbstractResponse
2424
*/
2525
public function xml2array(\SimpleXMLElement $xml)
2626
{
27+
return json_decode(json_encode($xml), true);
28+
2729
$arr = array();
2830
foreach ($xml as $element) {
2931
$tag = $element->getName();

src/Message/Query/QueryBatchDetailResponse.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function isSuccessful()
3939

4040
public function getData()
4141
{
42-
$result = $this->xml2array($this->data->transactions, true);
43-
return $result['transactions'][0]['transaction'];
42+
return $this->xml2array($this->data->transactions, true)['transaction'];
4443
}
4544
}

src/Message/Query/QueryBatchResponse.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function getResultCode()
5151

5252
public function getData()
5353
{
54-
$result = $this->xml2array($this->data->batchList, true);
55-
return $result['batchList'][0]['batch'];
54+
return $this->xml2array($this->data->batchList, true)['batch'];
5655
}
5756
}

src/Message/Query/QueryDetailResponse.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public function __construct(AbstractRequest $request, $data)
2929
}
3030

3131
parent::__construct($request, $xml);
32-
$result = $this->xml2array($this->data->transaction, true);
33-
$this->transaction = $result['transaction'][0];
32+
$this->transaction = $this->xml2array($this->data->transaction, true);
3433
}
3534

3635
public function isSuccessful()

src/Message/Query/QueryResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getData()
3737
'transactionReference' => $transaction['transId']
3838
))->send();
3939

40-
$result[] = $detailResponse;
40+
$result[] = $detailResponse->transaction;
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)