Decode.pm

filter: Statementstmt 91.1% 31 / 34 Branchbran 40.0% 4 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 80.0% 44 / 55 CC 8 SCAR 15.7
CC
8
Cov
78%
decode
8.8
import
3.0
BEGIN
1.0
CRAP 4.8
« Decode/Util.pm ↑ Summary Decode/Chain.pm »
1 package Data::Decode;
2 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use namespace::clean -except => qw(meta);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use Data::Decode::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Data::Decode::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 our $VERSION = '0.00007_01';
9  
10 7 has decoder => (
11 is => 'ro',
12 isa => 'Data::Decode::Decoder',
13 required => 1,
14 coerce => 1,
15 );
16  
17 7 ▶sub import {
Subroutine import: called CC=3 SCAR=11.1
18 7 my ( $self, @modules ) = @_;
19  
20 7 foreach my $class (@modules) {
21 4 ▶ if ($class !~ s/^\+//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class =~ s/^\+//) 4 0 4
22 4 $class = "Data::Decode::$class";
23 4 Class::MOP::load_class($class);
24 }
25 }
26 }
27  
28 10 ▶sub decode {
Subroutine decode: called CC=6 SCAR=21.8
Pod documented
29 10 my ($self, $data, $hints) = @_;
30  
31 10 ▶ return () unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 10 10
32 10 ▶ $hints ||= {};
Condition50%1/2
$hints ||= {}
l!l
010
MC/DC0%0/1
$hints ||= {}
$hints
Truth table50%1/2
A
A= $hints
Aresult
11
00
33  
34 10 my $ret = eval {
35 10 $self->decoder->decode($self, $data, $hints);
36 };
37 10 my $e;
38 10 ▶ if ($e = Data::Decode::Exception::Deferred->caught() ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e = 'Data::Decode::Exception::Deferred'->caught) { } 0 10 10
elsif ($e = 'Exception::Class'->caught) { } 0 10 10
39 # Just deferred. return ()
40 0 return ();
41 } elsif ( $e = Exception::Class->caught() ) {
42 # Oh, this we re-throw
43 0 ▶ eval { $e->isa('Data::Decode::Exception') } ?
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $e->isa('Data::Decode::Exception') } } ? : 0 0 0
44 $e->rethrow : die $e;
45 }
46 10 return $ret;
47 }
48  
49 7 1;
50  
51 __END__
« Decode/Util.pm ↑ Summary Decode/Chain.pm »