Skip to content

Commit 5369725

Browse files
committed
Small code tidy-up.
1 parent 6501825 commit 5369725

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/Message/AIMAbstractRequest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function setTransactionReference($value)
118118
$transactionRef = new TransactionReference();
119119
$transactionRef->setTransId($value);
120120
}
121+
121122
return $this->setParameter('transactionReference', $transactionRef);
122123
}
123124

@@ -130,6 +131,7 @@ public function setCardReference($value)
130131
if (!($value instanceof CardReference)) {
131132
$value = new CardReference($value);
132133
}
134+
133135
return parent::setCardReference($value);
134136
}
135137

@@ -140,15 +142,18 @@ public function setCardReference($value)
140142
public function getCardReference($serialize = true)
141143
{
142144
$value = parent::getCardReference();
145+
143146
if ($serialize) {
144147
$value = (string)$value;
145148
}
149+
146150
return $value;
147151
}
148152

149153
public function sendData($data)
150154
{
151155
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
156+
152157
$data = $data->saveXml();
153158
$httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
154159

@@ -162,10 +167,12 @@ public function sendData($data)
162167
public function getBaseData()
163168
{
164169
$data = new \SimpleXMLElement('<' . $this->requestType . '/>');
170+
165171
$data->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');
166172
$this->addAuthentication($data);
167173
$this->addReferenceId($data);
168174
$this->addTransactionType($data);
175+
169176
return $data;
170177
}
171178

@@ -178,6 +185,7 @@ protected function addAuthentication(\SimpleXMLElement $data)
178185
protected function addReferenceId(\SimpleXMLElement $data)
179186
{
180187
$txnId = $this->getTransactionId();
188+
181189
if (!empty($txnId)) {
182190
$data->refId = $this->getTransactionId();
183191
}
@@ -189,6 +197,7 @@ protected function addTransactionType(\SimpleXMLElement $data)
189197
// The extending class probably hasn't specified an "action"
190198
throw new InvalidRequestException();
191199
}
200+
192201
$data->transactionRequest->transactionType = $this->action;
193202
}
194203

@@ -214,7 +223,7 @@ protected function addBillingData(\SimpleXMLElement $data)
214223
if ($card = $this->getCard()) {
215224
// A card is present, so include billing and shipping details
216225
$req->customer->email = $card->getEmail();
217-
226+
218227
$req->billTo->firstName = $card->getBillingFirstName();
219228
$req->billTo->lastName = $card->getBillingLastName();
220229
$req->billTo->company = $card->getBillingCompany();

src/Message/CIMAbstractRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ public function setValidationMode($value)
2424
public function getValidationMode()
2525
{
2626
$validationMode = $this->getParameter('validationMode');
27+
2728
if ($validationMode !== self::VALIDATION_MODE_NONE) {
2829
$validationMode = $this->getDeveloperMode() ? self::VALIDATION_MODE_TEST : self::VALIDATION_MODE_LIVE;
2930
}
31+
3032
return $validationMode;
3133
}
3234

@@ -100,6 +102,7 @@ public function getDefaultBillTo()
100102
public function sendData($data)
101103
{
102104
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
105+
103106
$data = $data->saveXml();
104107
$httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
105108

src/Message/CIMAuthorizeRequest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ protected function addPayment(\SimpleXMLElement $data)
1515

1616
/** @var mixed $req */
1717
$req = $data->transactionRequest;
18+
1819
/** @var CardReference $cardRef */
1920
$cardRef = $this->getCardReference(false);
21+
2022
$req->profile->customerProfileId = $cardRef->getCustomerProfileId();
23+
2124
$req->profile->paymentProfile->paymentProfileId = $cardRef->getPaymentProfileId();
25+
2226
if ($shippingProfileId = $cardRef->getShippingProfileId()) {
2327
$req->profile->shippingProfileId = $shippingProfileId;
2428
}

tests/Message/AIMAbstractRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public function setUp()
1616
$this->request = $this->getMockForAbstractClass(
1717
'\Omnipay\AuthorizeNet\Message\AIMAbstractRequest',
1818
array(
19-
$this->getMock('\Guzzle\Http\ClientInterface'),
20-
$this->getMock('\Symfony\Component\HttpFoundation\Request')
19+
$this->createMock('\Guzzle\Http\ClientInterface'),
20+
$this->createMock('\Symfony\Component\HttpFoundation\Request')
2121
)
2222
);
2323
}

0 commit comments

Comments
 (0)