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

Commit

Permalink
added autoload-dev for tests, refactored Response to fit PSR-2 standard
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenobird authored and devheidelpay committed Aug 10, 2017
1 parent 59c3b93 commit 3dda12b
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 75 deletions.
101 changes: 53 additions & 48 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
{
"name" : "heidelpay/php-api",
"description" : "Client library for heidelpay payments.",
"license" : "Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.",
"authors" : [
{
"name" : "Jens Richter"
},
{
"name" : "Ronja Wann"
},
{
"name": "Stephano Vogel"
},
{
"name" : "Daniel Kraut"
}
],
"require" : {
"php" : ">=5.6.0",
"lib-curl" : "*",
"lib-openssl" : "*",
"ext-simplexml": "*"
},
"require-dev" : {
"phpunit/phpunit" : "~5.7",
"friendsofphp/php-cs-fixer" : "^2.0",
"satooshi/php-coveralls" : "^1.0",
"heidelpay/phpdocumentor" : "2.9.1"
},
"suggest": {
"heidelpay/php-customer-messages": "17.2.3"
},
"autoload" : {
"psr-4" : {
"Heidelpay\\PhpApi\\" : "lib"
}
},
"support" : {
"email" : "development@heidelpay.de"
},
"homepage" : "https://dev.heidelpay.de",
"type" : "library",
"keywords" : [
"payment-api",
"php",
"api",
"sdk"
]
"name": "heidelpay/php-api",
"description": "Client library for heidelpay payments.",
"license": "Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.",
"authors": [
{
"name": "Jens Richter"
},
{
"name": "Ronja Wann"
},
{
"name": "Stephano Vogel"
},
{
"name": "Daniel Kraut"
}
],
"require": {
"php": ">=5.6.0",
"lib-curl": "*",
"lib-openssl": "*",
"ext-SimpleXML": "*"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"friendsofphp/php-cs-fixer": "^2.0",
"satooshi/php-coveralls": "^1.0",
"heidelpay/phpdocumentor": "2.9.1"
},
"suggest": {
"heidelpay/php-customer-messages": "You can use this package to provide user-friendly messages instead of error codes."
},
"autoload": {
"psr-4": {
"Heidelpay\\PhpApi\\": "lib"
}
},
"autoload-dev": {
"psr-4": {
"Heidelpay\\Tests\\PhpApi\\": "tests"
}
},
"support": {
"email": "development@heidelpay.de"
},
"homepage": "https://dev.heidelpay.de",
"type": "library",
"keywords": [
"payment-api",
"php",
"api",
"sdk"
]
}
57 changes: 30 additions & 27 deletions lib/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class Response extends AbstractMethod
* The constructor will take a given response in post format and convert
* it to a response object
*
* @param array $RawResponse
* @param array $rawResponse
*/
public function __construct($RawResponse = null)
public function __construct($rawResponse = null)
{
if ($RawResponse !== null and is_array($RawResponse)) {
$this->splitArray($RawResponse);
if ($rawResponse !== null and is_array($rawResponse)) {
$this->splitArray($rawResponse);
}
}

Expand Down Expand Up @@ -81,67 +81,70 @@ public function getConnector()
/**
* Splits post array parameters and converts it to a response object
*
* @param array $RawResponse
* @param array $rawResponse
*
* @return \Heidelpay\PhpApi\Response
*/
public function splitArray($RawResponse)
public function splitArray($rawResponse)
{
foreach ($RawResponse as $ArrayKey => $ArrayValue) {
$ResponseGroup = explode('_', strtolower($ArrayKey), 2);
foreach ($rawResponse as $arrayKey => $arrayValue) {
$responseGroup = explode('_', strtolower($arrayKey), 2);

if (is_array($ResponseGroup)) {
switch ($ResponseGroup[0]) {
if (is_array($responseGroup)) {
switch ($responseGroup[0]) {
case 'address':
$this->getAddress()->set($ResponseGroup[1], $ArrayValue);
$this->getAddress()->set($responseGroup[1], $arrayValue);
break;
case 'account':
$this->getAccount()->set($ResponseGroup[1], $ArrayValue);
$this->getAccount()->set($responseGroup[1], $arrayValue);
break;
case 'basket':
$this->getBasket()->set($ResponseGroup[1], $ArrayValue);
$this->getBasket()->set($responseGroup[1], $arrayValue);
break;
case 'criterion':
$this->getCriterion()->set($ResponseGroup[1], $ArrayValue);
$this->getCriterion()->set($responseGroup[1], $arrayValue);
break;
case 'config':
$this->getConfig()->set($ResponseGroup[1], $ArrayValue);
$this->getConfig()->set($responseGroup[1], $arrayValue);
break;
case 'contact':
$this->getContact()->set($ResponseGroup[1], $ArrayValue);
$this->getContact()->set($responseGroup[1], $arrayValue);
break;
case 'connector':
$this->getConnector()->set($ResponseGroup[1], $ArrayValue);
$this->getConnector()->set($responseGroup[1], $arrayValue);
break;
case "frontend":
$this->getFrontend()->set($ResponseGroup[1], $ArrayValue);
$this->getFrontend()->set($responseGroup[1], $arrayValue);
break;
case "identification":
$this->getIdentification()->set($ResponseGroup[1], $ArrayValue);
$this->getIdentification()->set($responseGroup[1], $arrayValue);
break;
case "name":
$this->getName()->set($ResponseGroup[1], $ArrayValue);
$this->getName()->set($responseGroup[1], $arrayValue);
break;
case "payment":
$this->getPayment()->set($ResponseGroup[1], $ArrayValue);
$this->getPayment()->set($responseGroup[1], $arrayValue);
break;
case "presentation":
$this->getPresentation()->set($ResponseGroup[1], $ArrayValue);
$this->getPresentation()->set($responseGroup[1], $arrayValue);
break;
case "processing":
$this->getProcessing()->set($ResponseGroup[1], $ArrayValue);
$this->getProcessing()->set($responseGroup[1], $arrayValue);
break;
case "request":
$this->getRequest()->set($ResponseGroup[1], $ArrayValue);
$this->getRequest()->set($responseGroup[1], $arrayValue);
break;
case "riskinformation":
$this->getRequest()->set($responseGroup[1], $arrayValue);
break;
case "security":
$this->getSecurity()->set($ResponseGroup[1], $ArrayValue);
$this->getSecurity()->set($responseGroup[1], $arrayValue);
break;
case "transaction":
$this->getTransaction()->set($ResponseGroup[1], $ArrayValue);
$this->getTransaction()->set($responseGroup[1], $arrayValue);
break;
case "user":
$this->getUser()->set($ResponseGroup[1], $ArrayValue);
$this->getUser()->set($responseGroup[1], $arrayValue);
break;
}
}
Expand Down

0 comments on commit 3dda12b

Please sign in to comment.