PaymentsAdvanced/Role/HasTender.pm

filter: Statementstmt 100% 19 / 19 Branchbran n/a Conditioncond 93.3% 14 / 15 MC/DCmcdc 85.7% 6 / 7 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 95.7% 45 / 47 CC 6 SCAR 9.7
CC
6
Cov
97%
_build_is_paypal_transaction
4.0
_build_is_credit_card_transaction
3.0
BEGIN
1.0
CRAP 2.6
« PaymentsAdvanced/Response/SecureToken.pm ↑ Summary PaymentsAdvanced/Response.pm »
1 package WebService::PayPal::PaymentsAdvanced::Role::HasTender;
2  
3 6 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 our $VERSION = '0.000028';
8  
9 6 ▶use Types::Standard qw( Bool StrictNum );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has amount => (
12 is => 'lazy',
13 isa => StrictNum,
14 init_arg => undef,
15 5 ▶ default => sub { shift->params->{AMT} },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 6 );
17  
18 6 has is_credit_card_transaction => (
19 is => 'lazy',
20 isa => Bool,
21 init_arg => undef,
22 );
23  
24 6 has is_paypal_transaction => (
25 is => 'lazy',
26 isa => Bool,
27 lazy => 1,
28 init_arg => undef,
29 );
30  
31 33 ▶sub _build_is_credit_card_transaction {
Subroutine _build_is_credit_card_transaction: called CC=3 SCAR=11.0
32 33 my $self = shift;
33 return ( exists $self->params->{TENDER}
34 && $self->params->{TENDER} eq 'CC' )
35 33 ▶ || exists $self->params->{CARDTYPE};
Condition100%6/6
exists $self->params->{'TENDER'} && $self->params->{'TENDER'} eq 'CC' || exists $self->params->{'CARDTYPE'}
l!l&&r!l&&!r
2166
exists $self->params->{"TENDER"} and $self->params->{"TENDER"} eq "CC"
!ll&&!rl&&r
10221
MC/DC100%3/3
exists $self->params->{'TENDER'} && $self->params->{'TENDER'} eq 'CC' || exists $self->params->{'CARDTYPE'}
exists $self->params->{"TENDER"} $self->params->{"TENDER"} eq "CC" exists $self->params->{'CARDTYPE'}
Truth table80%4/5
A and B || C
A= exists $self->params->{"TENDER"}B= $self->params->{"TENDER"} eq "CC"C= exists $self->params->{'CARDTYPE'}
ABCresult
11X1
0X11
1011
0X00
1000
36 }
37  
38 12 ▶sub _build_is_paypal_transaction {
Subroutine _build_is_paypal_transaction: called CC=4 SCAR=13.9
39 12 my $self = shift;
40 return ( exists $self->params->{TENDER}
41 && $self->params->{TENDER} eq 'P' )
42 || exists $self->params->{BAID}
43 12 ▶ || !$self->is_credit_card_transaction;
Condition88%8/9
exists $self->params->{'TENDER'} && $self->params->{'TENDER'} eq 'P' || exists $self->params->{'BAID'} || !$self->is_credit_card_transaction
l!l&&r!l&&!r
309
exists $self->params->{"TENDER"} and $self->params->{"TENDER"} eq "P" or exists $self->params->{"BAID"}
l!l&&r!l&&!r
129
exists $self->params->{"TENDER"} and $self->params->{"TENDER"} eq "P"
!ll&&!rl&&r
561
MC/DC75%3/4
exists $self->params->{'TENDER'} && $self->params->{'TENDER'} eq 'P' || exists $self->params->{'BAID'} || !$self->is_credit_card_transaction
exists $self->params->{"TENDER"} $self->params->{"TENDER"} eq "P" exists $self->params->{"BAID"} !$self->is_credit_card_transaction
Truth table57%4/7
A and B or C || not(D)
A= exists $self->params->{"TENDER"}B= $self->params->{"TENDER"} eq "P"C= exists $self->params->{"BAID"}D= !$self->is_credit_card_transaction
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
44 }
45  
46 6 1;
47  
48 =pod
49  
50 =encoding UTF-8
51  
52 =head1 NAME
53  
54 WebService::PayPal::PaymentsAdvanced::Role::HasTender - Role which provides some methods describing a transaction
55  
56 =head1 VERSION
57  
58 version 0.000028
59  
60 =head2 amount
61  
62 The C<AMT> param
63  
64 =head2 is_credit_card_transaction
65  
66 C<Boolean>. Returns true if this is a credit card transaction.
67  
68 =head2 is_paypal_transaction
69  
70 C<Boolean>. Returns true if this is a PayPal transaction.
71  
72 =head1 SUPPORT
73  
74 Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>.
75  
76 =head1 AUTHOR
77  
78 Olaf Alders <olaf@wundercounter.com>
79  
80 =head1 COPYRIGHT AND LICENSE
81  
82 This software is copyright (c) 2022 by MaxMind, Inc.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
88  
89 __END__
« PaymentsAdvanced/Response/SecureToken.pm ↑ Summary PaymentsAdvanced/Response.pm »