| Total Complexity | 13 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class CreditCard extends \Faker\Provider\Payment implements \Validate\Contracts\Validate |
||
| 9 | { |
||
| 10 | use MaskTrait; |
||
| 11 | |||
| 12 | public static function toDatabase($creditCardNumber) |
||
| 13 | { |
||
| 14 | return strtoupper(preg_replace('/[^0-9]/', '', $creditCardNumber)); |
||
| 15 | } |
||
| 16 | |||
| 17 | public static function toUser($creditCardNumber) |
||
| 18 | { |
||
| 19 | return strtoupper(preg_replace('/[^0-9]/', '', $creditCardNumber)); |
||
| 20 | } |
||
| 21 | |||
| 22 | public static function validate($creditCardNumber) |
||
| 23 | { |
||
| 24 | $found = false; |
||
| 25 | foreach (self::$cardParams as $masks){ |
||
| 26 | foreach ($masks as $mask){ |
||
| 27 | if (self::maskIsValidate($creditCardNumber, $mask)) { |
||
| 28 | $found = true; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 | return $found; |
||
| 33 | } |
||
| 34 | |||
| 35 | public static function expirationIsValid($mes, $ano) |
||
| 36 | { |
||
| 37 | if ((int) Date::yearToDatabase($ano) < (int) Carbon::now()->year) { |
||
| 38 | return false; |
||
| 39 | } |
||
| 40 | if ((int) Date::yearToDatabase($ano) == (int) Carbon::now()->year) { |
||
| 41 | if ((int) Date::monthToDatabase($mes) < (int) Carbon::now()->month) { |
||
| 42 | return false; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | return true; |
||
| 46 | } |
||
| 47 | |||
| 48 | public static function month($year) |
||
| 51 | } |
||
| 52 | |||
| 53 | public static function year($year) |
||
| 54 | { |
||
| 55 | return Date::yearToDatabase($year); |
||
| 56 | } |
||
| 57 | |||
| 58 | public static function isSame(string $to, string $from) |
||
| 61 | } |
||
| 62 | |||
| 63 | } |
||
| 64 |