Decode/Chain.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 88.1% 37 / 42 CC 5 SCAR 11.8
CC
5
Cov
86%
decode
5.5
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
« Decode.pm ↑ Summary Decode/Types.pm »
1  
2 package Data::Decode::Chain;
3 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use MooseX::AttributeHelpers;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use namespace::clean -except => qw(meta);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Data::Decode::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Data::Decode::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 has decoders => (
10 metaclass => 'Collection::Array',
11 is => 'ro',
12 isa => 'Data::Decode::DecoderList',
13 required => 1,
14 coerce => 1,
15 provides => {
16 elements => 'all_decoders',
17 }
18 );
19  
20 5 ▶sub decode {
Subroutine decode: called CC=5 SCAR=17.1
Pod documented
21 5 my ($self, $decoder, $string, $hints) = @_;
22  
23 5 my $ret;
24 5 foreach my $decoder ($self->all_decoders) {
25 8 $ret = eval {
26 8 $decoder->decode($decoder, $string, $hints);
27 };
28 8 my $e;
29 8 ▶ if ($e = Data::Decode::Exception::Deferred->caught() ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e = 'Data::Decode::Exception::Deferred'->caught) { } 3 5 8
elsif ($e = 'Exception::Class'->caught) { } 0 5 5
30 # Decoding was deffered, we don't do anything about this
31 # error, and simply let the next decoder attempt to handle
32 # this particular set of inputs.
33 3 next;
34 } elsif ( $e = Exception::Class->caught() ) {
35 # This is a generic error, just propagate it
36 0 ▶ eval { $e->isa('Data::Decode::Exception') } ?
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $e->isa('Data::Decode::Exception') } } ? : 0 0 0
37 $e->rethrow : die $e;
38 }
39 5 last;
40 }
41  
42 5 return $ret;
43 }
44  
45 4 1;
46  
47 __END__
« Decode.pm ↑ Summary Decode/Types.pm »