| 1 | package MooseX::Types::CreditCard; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | our $VERSION = '0.002003'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use MooseX::Types -declare => [ qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | CreditCard | ||||||||||||||||||||||||||||||||||||||||||
| 10 | CardNumber | ||||||||||||||||||||||||||||||||||||||||||
| 11 | CardSecurityCode | ||||||||||||||||||||||||||||||||||||||||||
| 12 | CardExpiration | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ) ]; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Module::Runtime qw( use_module ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use MooseX::Types::Moose qw( Str Int HashRef ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use MooseX::Types::Common::String 0.001005 qw( NumericCode ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ▶ | use MooseX::Types::DateTime (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | subtype CardNumber, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | as NumericCode, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | length($_) <= 20 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
length $_ <= 20 and length $_ >= 12 and &use_module("Business::CreditCard")
length $_ <= 20 and length $_ >= 12
MC/DC0%0/3
length $_ <= 20 and length $_ >= 12 and &use_module("Business::CreditCard")
length $_ <= 20
length $_ >= 12
&use_module("Business::CreditCard")
Truth table25%1/4
A and B and C
A= length $_ <= 20B= length $_ >= 12C= &use_module("Business::CreditCard")
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | && length $_ >= 12 | ||||||||||||||||||||||||||||||||||||||||||
| 26 | && use_module('Business::CreditCard') | ||||||||||||||||||||||||||||||||||||||||||
| 27 | && Business::CreditCard::validate($_) | ||||||||||||||||||||||||||||||||||||||||||
| 28 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | message {'"'. $_ . '" is not a valid credit card number' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | subtype CardSecurityCode, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | as NumericCode, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | length $_ >= 3 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $_ >= 3 and length $_ <= 4
MC/DC100%2/2
length $_ >= 3 and length $_ <= 4
length $_ >= 3
length $_ <= 4
Truth table100%3/3
A and B
A= length $_ >= 3B= length $_ <= 4
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | && length $_ <= 4 | ||||||||||||||||||||||||||||||||||||||||||
| 37 | && $_ =~ /^[0-9]+$/xms | ||||||||||||||||||||||||||||||||||||||||||
| 38 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | message { '"' | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | . $_ | ||||||||||||||||||||||||||||||||||||||||||
| 41 | . '" is not a valid credit card security code. Must be 3 or 4 digits' | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | subtype CardExpiration, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | as MooseX::Types::DateTime::DateTime, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | my ( $month, $year ) = ( $_->month, $_->year ); | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | my $comparitor | |||||||||||||||||||||||||||||||||||||||||
| 50 | = use_module('DateTime') | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ->last_day_of_month( month => $month, year => $year ) | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | return 0 unless DateTime->compare( $_, $comparitor ) == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | message { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | 'DateTime object is not the last day of month'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | subtype CreditCard, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | as CardNumber, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | our @CARP_NOT = qw( Moose::Meta::TypeConstraint ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | use_module('Carp'); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | Carp::carp 'DEPRECATED: use CardNumber instead of CreditCard Type'; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | }, # just for backcompat | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | message {'"'. $_ . '" is not a valid credit card number' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | coerce CardNumber, from Str, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | via { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | my $int = $_; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | $int =~ tr/0-9//cd; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | return $int; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | message {'"'. $_ . '" is not a valid credit card number' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | coerce CreditCard, from Str, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | via { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my $int = $_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | $int =~ tr/0-9//cd; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | return $int; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | message {'"'. $_ . '" is not a valid credit card number' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | coerce CardExpiration, from HashRef, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | via { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return use_module('DateTime')->last_day_of_month( %{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | # ABSTRACT: Moose Types related to Credit Cards | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | __END__ | ||||||||||||||||||||||||||||||||||||||||||