MWS/TypeMap.pm

filter: Statementstmt 87.5% 28 / 32 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 66.6% 2 / 3 totaltotal 80.7% 42 / 52 CC 3 SCAR 6.3
CC
3
Cov
81%
__ANON__
6.0
__ANON__
2.1
__ANON__
2.0
CRAP 1.9
« MWS/Enumeration/Schedule.pm ↑ Summary MWS/Orders.pm »
1 package Amazon::MWS::TypeMap;
2  
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 our @EXPORT_OK = qw(from_amazon to_amazon);
11 8 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
12  
13 1 ▶sub identity { shift }
Subroutine identity: called CC=1 SCAR=0.0
Pod undocumented
14  
15 my %from_map = (
16 'string' => \&identity,
17 0 ▶ 'boolean' => sub { lc(shift) eq 'true' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 'nonNegativeInteger' => \&identity,
19 1 ▶ 'datetime' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1 return DateTime::Format::ISO8601->parse_datetime(shift);
21 },
22 8 );
23  
24 1 ▶sub from_amazon {
Subroutine from_amazon: called CC=1 SCAR=0.0
Pod documented
25 1 my ($type, $value) = @_;
26 1 return $from_map{$type}->($value);
27 }
28  
29 my %to_map = (
30 'string' => \&identity,
31 1 ▶ 'boolean' => sub { $_[0] ? 'true' : 'false' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 1 1
32 0 ▶ 'nonNegativeInteger' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
33 0 my $int = int(shift);
34 0 ▶ $int = 1 unless $int > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $int > 0 0 0 0
35 0 return $int;
36 },
37 2 ▶ 'datetime' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 2 return DateTime::Format::ISO8601->parse_datetime(shift);
39 },
40 8 );
41  
42 4 ▶sub to_amazon {
Subroutine to_amazon: called CC=1 SCAR=0.0
Pod documented
43 4 my ($type, $value) = @_;
44 4 return $to_map{$type}->($value);
45 }
46  
47 8 1;
48  
49 __END__
« MWS/Enumeration/Schedule.pm ↑ Summary MWS/Orders.pm »