Skip to content

Commit 9fe28d8

Browse files
authored
Merge pull request #170 from artspeople/issue-169
Clarify exception message for credit cards
2 parents 1376019 + 1d8eca1 commit 9fe28d8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Common/CreditCard.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,15 @@ protected function setYearParameter($key, $value)
274274
*/
275275
public function validate()
276276
{
277-
foreach (array('number', 'expiryMonth', 'expiryYear') as $key) {
277+
$requiredParameters = array(
278+
'number' => 'credit card number',
279+
'expiryMonth' => 'expiration month',
280+
'expiryYear' => 'expiration year'
281+
);
282+
283+
foreach ($requiredParameters as $key => $val) {
278284
if (!$this->getParameter($key)) {
279-
throw new InvalidCreditCardException("The $key parameter is required");
285+
throw new InvalidCreditCardException("The $val is required");
280286
}
281287
}
282288

tests/Omnipay/Common/CreditCardTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testValidateFixture()
5757

5858
/**
5959
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
60-
* @expectedExceptionMessage The number parameter is required
60+
* @expectedExceptionMessage The credit card number is required
6161
*/
6262
public function testValidateNumberRequired()
6363
{
@@ -67,7 +67,7 @@ public function testValidateNumberRequired()
6767

6868
/**
6969
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
70-
* @expectedExceptionMessage The expiryMonth parameter is required
70+
* @expectedExceptionMessage The expiration month is required
7171
*/
7272
public function testValidateExpiryMonthRequired()
7373
{
@@ -77,7 +77,7 @@ public function testValidateExpiryMonthRequired()
7777

7878
/**
7979
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
80-
* @expectedExceptionMessage The expiryYear parameter is required
80+
* @expectedExceptionMessage The expiration year is required
8181
*/
8282
public function testValidateExpiryYearRequired()
8383
{

0 commit comments

Comments
 (0)