Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

before_script:
- composer install
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.6.0",
"lib-pcre": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "4.7.*"
"phpunit/phpunit": "^5"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 24 additions & 0 deletions src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ class CreditCard
),
);

/**
* Validate credit card number
*
* @param string|int $number
* @param string $type
*
* @return array
*/
public static function validCreditCard($number, $type = null)
{
$ret = array(
Expand All @@ -122,11 +130,27 @@ public static function validCreditCard($number, $type = null)
return $ret;
}

/**
* Validate card cvc code
*
* @param string|int $cvc
* @param string $type
*
* @return bool
*/
public static function validCvc($cvc, $type)
{
return (ctype_digit($cvc) && array_key_exists($type, self::$cards) && self::validCvcLength($cvc, $type));
}

/**
* Validate card experience date
*
* @param string|int $year
* @param string|int $month
*
* @return bool
*/
public static function validDate($year, $month)
{
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
Expand Down