Business/CyberSource/Request.pm

filter: Statementstmt 87.7% 50 / 57 Branchbran 33.3% 2 / 6 Conditioncond 55.5% 5 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 90.9% 10 / 11 Podpod 100% 1 / 1 totaltotal 78.6% 70 / 89 CC 7 SCAR 18.2
CC
7
Cov
79%
add_item
20.0
__ANON__
4.0
BEGIN
1.0
CRAP 6.2
« Business/CyberSource/Rule/RequestIDisZero.pm ↑ Summary Business/CyberSource/RequestPart/Card.pm »
1 package Business::CyberSource::Request;
2 17 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 our $VERSION = '0.010008'; # VERSION
8  
9 17 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 17 extends 'Business::CyberSource::Message';
11 17 with qw(
12 MooseX::RemoteHelper::CompositeSerialization
13 );
14  
15 17 ▶use MooseX::Types::CyberSource qw( PurchaseTotals Service Items InvoiceHeader OtherTax ShipFrom ShipTo );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 17 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 17 our @CARP_NOT = ( 'Class::MOP::Method::Wrapped', __PACKAGE__ );
20  
21 10 ▶before serialize => sub { ## no critic qw( Subroutines::RequireFinalReturn )
Subroutine __ANON__: called CC=4 SCAR=13.9
22 10 my $self = shift;
23  
24 10 ▶ if ( !$self->has_total && ( !$self->has_items || $self->items_is_empty ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->has_total and !$self->has_items || $self->items_is_empty) 1 9 10
Condition83%5/6
not $self->has_total and !$self->has_items || $self->items_is_empty
!ll&&!rl&&r
811
not $self->has_items or $self->items_is_empty
l!l&&r!l&&!r
101
MC/DC66%2/3
not $self->has_total and !$self->has_items || $self->items_is_empty
not $self->has_total not $self->has_items $self->items_is_empty
Truth table75%3/4
not(A) and not(B) or C
A= not $self->has_totalB= not $self->has_itemsC= $self->items_is_empty
ABCresult
0XX0
1000
11X1
1011
25 1 die ## no critic ( ErrorHandling::RequireCarping )
26 use_module('Business::CyberSource::Exception::ItemsOrTotal')->new;
27 }
28 17 };
29  
30 0 ▶sub add_item {
Subroutine add_item: not called CC=4 SCAR=30.0
Pod documented
31 0 my ( $self, $args ) = @_;
32  
33 0 my $item;
34 0 ▶ unless ( blessed $args
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($args) and $args->isa('Business::CyberSource::RequestPart::Item')) { } 0 0 0
Condition0%0/3
builtin::blessed($args) and $args->isa("Business::CyberSource::RequestPart::Item")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($args) and $args->isa("Business::CyberSource::RequestPart::Item")
builtin::blessed($args) $args->isa("Business::CyberSource::RequestPart::Item")
Truth table0%0/3
A and B
A= builtin::blessed($args)B= $args->isa("Business::CyberSource::RequestPart::Item")
ABresult
0X0
100
111
35 && $args->isa('Business::CyberSource::RequestPart::Item') )
36 {
37 0 $item =
38 use_module('Business::CyberSource::RequestPart::Item')->new($args);
39 }
40 else {
41 0 $item = $args;
42 }
43 0 ▶ $self->items( [] ) if !$self->has_items;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_items 0 0 0
44  
45 0 return $self->_push_item($item);
46 }
47  
48 1 ▶sub _build_service {
Subroutine _build_service: called CC=1 SCAR=0.0
49 1 return use_module('Business::CyberSource::RequestPart::Service')->new;
50 }
51  
52 17 has comments => (
53 remote_name => 'comments',
54 isa => 'Str',
55 traits => ['SetOnce'],
56 is => 'rw',
57 );
58  
59 17 has service => (
60 isa => Service,
61 is => 'ro',
62 lazy_build => 1,
63 required => 1,
64 coerce => 1,
65 reader => undef,
66 );
67  
68 17 has purchase_totals => (
69 isa => PurchaseTotals,
70 remote_name => 'purchaseTotals',
71 is => 'ro',
72 required => 1,
73 coerce => 1,
74 handles => [qw( total has_total discount has_discount duty has_duty )],
75 );
76  
77 has items => (
78 isa => Items,
79 remote_name => 'item',
80 predicate => 'has_items',
81 is => 'rw',
82 traits => ['Array'],
83 coerce => 1,
84 handles => {
85 items_is_empty => 'is_empty',
86 next_item => [ natatime => 1 ],
87 list_items => 'elements',
88 _push_item => 'push',
89 },
90 1 ▶ serializer => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
91 1 my ( $attr, $instance ) = @_;
92  
93 1 my $items = $attr->get_value($instance);
94  
95 1 my $i = 0;
96 my @serialized =
97 map { ## no critic ( BuiltinFunctions::ProhibitComplexMappings )
98 2 my $item = $_->serialize;
99 2 $item->{id} = $i;
100 2 $i++;
101 2 $item
102 1 } @{$items};
103  
104 1 return \@serialized;
105 },
106 17 );
107  
108 17 has '+http_trace' => (
109 is => 'rw',
110 init_arg => undef
111 );
112  
113 17 has 'invoice_header' => (
114 isa => InvoiceHeader,
115 remote_name => 'invoiceHeader',
116 is => 'ro',
117 required => 0,
118 coerce => 1
119 );
120  
121 17 has ship_to => (
122 isa => ShipTo,
123 remote_name => 'shipTo',
124 is => 'ro',
125 coerce => 1,
126 );
127  
128 17 has 'other_tax' => (
129 isa => OtherTax,
130 remote_name => 'otherTax',
131 is => 'ro',
132 required => 0,
133 coerce => 1,
134 );
135  
136 17 has 'ship_from' => (
137 isa => ShipFrom,
138 remote_name => 'shipFrom',
139 is => 'ro',
140 required => 0,
141 coerce => 1,
142 );
143  
144 17 __PACKAGE__->meta->make_immutable;
145 17 1;
146  
147 # ABSTRACT: Abstract Request Class
148  
149 __END__
« Business/CyberSource/Rule/RequestIDisZero.pm ↑ Summary Business/CyberSource/RequestPart/Card.pm »