8000 PSR correction · dercoder/omnipay-ecopayz@2efb500 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2efb500

Browse files
committed
PSR correction
1 parent 8da1792 commit 2efb500

13 files changed

+149
-294
lines changed

src/Omnipay/Ecopayz/Gateway.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function setMerchantAccountNumber($value)
117117
}
118118

119119
/**
120-
* @param array $parameters
120+
* @param array $parameters
121121
* @return \Omnipay\Ecopayz\Message\PurchaseRequest
122122
*/
123123
public function purchase(array $parameters = array())
@@ -126,7 +126,7 @@ public function purchase(array $parameters = array())
126126
}
127127

128128
/**
129-
* @param array $parameters
129+
* @param array $parameters
130130
* @return \Omnipay\Ecopayz\Message\CompletePurchaseRequest
131131
*/
132132
public function completePurchase(array $parameters = array())
@@ -135,7 +135,7 @@ public function completePurchase(array $parameters = array())
135135
}
136136

137137
/**
138-
* @param array $parameters
138+
* @param array $parameters
139139
* @return \Omnipay\Ecopayz\Message\PayoutRequest
140140
*/
141141
public function payout(array $parameters = array())
@@ -144,7 +144,7 @@ public function payout(array $parameters = array())
144144
}
145145

146146
/**
147-
* @param array $parameters
147+
* @param array $parameters
148148
* @return \Omnipay\Ecopayz\Message\FetchTransactionRequest
149149
*/
150150
public function fetchTransaction(array $parameters = array())

src/Omnipay/Ecopayz/Message/AbstractRequest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
1515
/**
1616
* Get the Merchant ID
1717
*
18-
* This is the merchant number and is a four digit numeric value, this is entered by EcoPayz staff at import time.
18+
* This is the merchant number and is a four digit numeric value,
19+
* this is entered by EcoPayz staff at import time.
1920
* If this is known this can be entered on submission
2021
*
2122
* @return string merchant id
@@ -28,7 +29,8 @@ public function getMerchantId()
2829
/**
2930
* Set the Merchant ID
3031
*
31-
* This is the merchant number and is a four digit numeric value, this is entered by EcoPayz staff at import time.
32+
* This is the merchant number and is a four digit numeric value,
33+
* this is entered by EcoPayz staff at import time.
3234
* If this is known this can be entered on submission
3335
*
3436
* @param string $value merchant id
@@ -69,7 +71,8 @@ public function setMerchantPassword($value)
6971
/**
7072
* Get the Merchant Account Number
7173
*
72-
* The merchant’s ecoPayz account number, which will be credited by the purchase transaction.
74+
* The merchant’s ecoPayz account number,
75+
* which will be credited by the purchase transaction.
7376
* The number is provided by ecoPayz.
7477
*
7578
* @return string merchant account number
@@ -82,7 +85,8 @@ public function getMerchantAccountNumber()
8285
/**
8386
* Set the Merchant Account Number
8487
*
85-
* The merchant’s ecoPayz account number, which will be credited by the purchase transaction.
88+
* The merchant’s ecoPayz account number,
89+
* which will be credited by the purchase transaction.
8690
* The number is provided by ecoPayz.
8791
*
8892
* @param string $value merchant account number
@@ -96,12 +100,12 @@ public function setMerchantAccountNumber($value)
96100
/**
97101
* Get calcuated checksom
98102
*
99-
* The purpose of the checksum is to authenticate the communicating parties (the merchant system and the ecoPayz system)
103+
* The purpose of the checksum is to authenticate the communicating parties
100104
* and to ensure the integrity of the data they send each other.
101105
* The checksum is an MD5 hash, which is 128 bits or 16 bytes long.
102106
* The value is expressed as a string of hexadecimal digits in lowercase
103107
*
104-
* @param array $data data to calculate checksum
108+
* @param array $data data to calculate checksum
105109
* @return string checksum
106110
*/
107111
protected function calculateArrayChecksum(array $data)
@@ -118,18 +122,15 @@ protected function calculateArrayChecksum(array $data)
118122
* 4. Compute the MD5 hash of the byte array.
119123
* 5. Convert the hash to a string, using lowercase hexadecimal digits.
120124
* 6. Replace the Merchant password in XML’s element Checksum with the hash string.
121-
* 7. Send the response AS IS: do not re-format it in any way; keep the original indentation, whitespaces, etc.
125+
* 7. Send the response AS IS: do not re-format it in any way.
122126
*
123127
* @param string $string xml string to calculate checksum
124128
* @return string checksum
125129
*/
126130
protected function calculateXmlChecksum($string)
127131
{
128132

129-
$trimmedString = trim($string);
130-
$formatedString = str_replace(array("\r\n", "\r", "\n"), '', $trimmedString);
131-
132-
return md5($formatedString);
133+
return md5(str_replace(array("\r\n", "\r", "\n"), '', trim($string)));
133134

134135
}
135136

src/Omnipay/Ecopayz/Message/CompletePurchaseRequest.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CompletePurchaseRequest extends FetchTransactionRequest
2424
* Get the data for this request.
2525
*
2626
* @throws InvalidRequestException
27-
* @return string request data
27+
* @return string request data
2828
*/
2929
public function getData()
3030
{
@@ -51,7 +51,6 @@ public function getData()
5151
return new \SimpleXMLElement($xml);
5252

5353
} elseif ($xml = $this->httpRequest->getContent()) {
54-
5554
return new \SimpleXMLElement($xml);
5655

5756
} else {
@@ -65,7 +64,7 @@ public function getData()
6564
/**
6665
* Send the request with specified data
6766
*
68-
* @param mixed $data The data to send
67+
* @param mixed $data The data to send
6968
* @return FetchTransactionResponse
7069
*/
7170
public function sendData($data)
@@ -86,7 +85,6 @@ public function sendData($data)
8685
die();
8786

8887
} else {
89-
9088
return new CompletePurchaseResponse($this, $data);
9189
}
9290

@@ -101,9 +99,9 @@ public function sendData($data)
10199
* - Confirmed
102100
* - Cancelled
103101
*
104-
* @param string $status The ecopayz status code
105-
* @param int $errorCode The merchant error code
106-
* @param string $errorDescription The merchant error description
102+
* @param string $status The ecopayz status code
103+
* @param int $errorCode The merchant error code
104+
* @param string $errorDescription The merchant error description
107105
* @return string response
108106
*/
109107
public function createResponse($status, $errorCode, $errorDescription)
@@ -120,10 +118,17 @@ public function createResponse($status, $errorCode, $errorDescription)
120118
$document->createElement('TransactionResult')
121119
);
122120

123-
$result->appendChild($document->createElement('Description', $errorDescription));
124-
$result->appendChild($document->createElement('Code', $errorCode));
121+
$result->appendChild(
122+
$document->createElement('Description', $errorDescription)
123+
);
124+
125+
$result->appendChild(
126+
$document->createElement('Code', $errorCode)
127+
);
125128

126-
$response->appendChild($document->createElement('Status', $status));
129+
$response->appendChild(
130+
$document->createElement('Status', $status)
131+
);
127132

128133
$authentication = $response->appendChild(
129134
$document->createElement('Authentication')
@@ -142,14 +147,14 @@ public function createResponse($status, $errorCode, $errorDescription)
142147
/**
143148
* Validate Ecopayz XML message
144149
*
145-
* @param string $string The xml string to validate
146-
* @return bool result
150+
* @param string $string The xml string to validate
151+
* @return bool result
147152
*/
148153
public function validateChecksum($string)
149154
{
150155

151156
$xml = new \SimpleXMLElement($string);
152-
$checksum = (string)$xml->Authentication->Checksum;
157+
$checksum = (string) $xml->Authentication->Checksum;
153158
$original = str_replace($checksum, $this->getMerchantPassword(), $string);
154159

155160
return md5($original) == $checksum;

src/Omnipay/Ecopayz/Message/CompletePurchaseResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CompletePurchaseResponse extends FetchTransactionResponse
1919
*/
2020
public function getTransactionId()
2121
{
22-
return (string)$this->data->ClientTransactionID;
22+
return (string) $this->data->ClientTransactionID;
2323
}
2424

2525
/**
@@ -29,7 +29,7 @@ public function getTransactionId()
2929
*/
3030
public function getTransactionReference()
3131
{
32-
return (string)$this->data->SvsTxID;
32+
return (string) $this->data->SvsTxID;
3333
}
3434

3535
}

src/Omnipay/Ecopayz/Message/FetchTransactionRequest.php

Lines changed: 34 additions & 14 deletions
+
$request->appendChild(
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FetchTransactionRequest extends AbstractRequest
2121
* Get the data for this request.
2222
*
2323
* @throws InvalidRequestException
24-
* @return string request data
24+
* @return string request data
2525
*/
2626
public function getData()
2727
{
@@ -56,9 +56,17 @@ public function getData()
5656
$document->createElement('q0:QueryBySVSTransactionIDRequest')
5757
);
5858

59-
$request->appendChild($document->createElement('q0:MerchantID', $this->getMerchantId()));
60-
$request->appendChild($document->createElement('q0:MerchantPassword', $this->getMerchantPassword()));
61-
$request->appendChild($document->createElement('q0:SVSTxID', $transactionReference));
59+
$request->appendChild(
60+
$document->createElement('q0:MerchantID', $this->getMerchantId())
61+
);
62+
63+
$request->appendChild(
64+
$document->createElement('q0:MerchantPassword', $this->getMerchantPassword())
65+
);
66+
67+
$request->appendChild(
68+
$document->createElement('q0:SVSTxID', $transactionReference)
69+
);
6270

6371
} elseif ($transactionId = $this->getTransactionId()) {
6472

@@ -70,9 +78,17 @@ public function getData()
7078
$document->createElement('q0:QueryByCustomerTransactionIDRequest')
7179
);
7280

73-
$request->appendChild($document->createElement('q0:MerchantID', $this->getMerchantId()));
74-
$request->appendChild($document->createElement('q0:MerchantPassword', $this->getMerchantPassword()));
75-
$request->appendChild($document->createElement('q0:TxID', $transactionId));
81+
$request->appendChild(
82+
$document->createElement('q0:MerchantID', $this->getMerchantId())
83+
);
84+
85
86+
$document->createElement('q0:MerchantPassword', $this->getMerchantPassword())
87+
);
88+
89+
$request->appendChild(
90+
$document->createElement('q0:TxID', $transactionId)
91+
);
7692

7793
} else {
7894

@@ -87,7 +103,7 @@ public function getData()
87103
/**
88104
* Send the request with specified data
89105
*
90-
* @param mixed $data The data to send
106+
* @param mixed $data The data to send
91107
* @throws InvalidResponseException
92108
* @throws InvalidRequestException
93109
* @return FetchTransactionResponse
@@ -109,14 +125,16 @@ public function sendData($data)
109125
->children('http://www.ecocard.com/merchantAPI/');
110126

111127
if (!isset($xmlResponse->QueryBySVSTransactionIDResponse)) {
112-
throw new InvalidResponseException('Missing "QueryBySVSTransactionIDResponse" element in XML response');
128+
throw new InvalidResponseException('Missing element in XML response');
113129
}
114130

115131
if (!isset($xmlResponse->QueryBySVSTransactionIDResponse->TransactionResponse)) {
116-
throw new InvalidResponseException('Missing "QueryBySVSTransactionIDResponse/TransactionResponse" element in XML response');
132+
throw new InvalidResponseException('Missing element in XML response');
117133
}
118134

119-
return new FetchTransactionResponse($this, $xmlResponse->QueryBySVSTransactionIDResponse->TransactionResponse);
135+
return new FetchTransactionResponse($this, $xmlResponse
136+
->QueryBySVSTransactionIDResponse
137+
->TransactionResponse);
120138

121139
} elseif (strpos($data, 'QueryByCustomerTransactionID') !== false) {
122140

@@ -132,14 +150,16 @@ public function sendData($data)
132150
->children('http://www.ecocard.com/merchantAPI/');
133151

134152
if (!isset($xmlResponse->QueryByCustomerTransactionIDResponse)) {
135-
throw new InvalidResponseException('Missing "QueryByCustomerTransactionIDResponse" element in XML response');
153+
throw new InvalidResponseException('Missing element in XML response');
136154
}
137155

138156
if (!isset($xmlResponse->QueryByCustomerTransactionIDResponse->TransactionResponse)) {
139-
throw new InvalidResponseException('Missing "QueryByCustomerTransactionIDResponse/TransactionResponse" element in XML response');
157+
throw new InvalidResponseException('Missing element in XML response');
140158
}
141159

142-
return new FetchTransactionResponse($this, $xmlResponse->QueryByCustomerTransactionIDResponse->TransactionResponse);
160+
return new FetchTransactionResponse($this, $xmlResponse
161+
->QueryByCustomerTransactionIDResponse
162+
->TransactionResponse);
143163

144164
} else {
145165

0 commit comments

Comments
 (0)
0