Builder/Parser/Dispatch.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 81.8% 54 / 66 CC 9 SCAR 19.2
CC
9
Cov
85%
__ANON__
10.7
create_parser
1.0
BEGIN
1.0
CRAP 6.8
« Builder/Parser/Quick.pm ↑ Summary Builder/Parser.pm »
1 package DateTime::Format::Builder::Parser::Dispatch;
2  
3 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 24 our $VERSION = '0.83';
7  
8 24 our %dispatch_data;
9 24 ▶use Params::Validate qw( CODEREF validate );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 24 ▶use DateTime::Format::Builder::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 {
13 24 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 24 *dispatch_data = *DateTime::Format::Builder::dispatch_data;
15 24 *params = *DateTime::Format::Builder::Parser::params;
16 }
17  
18 DateTime::Format::Builder::Parser->valid_params(
19 24 Dispatch => {
20 type => CODEREF,
21 }
22 );
23  
24 2 ▶sub create_parser {
Subroutine create_parser: called CC=1 SCAR=0.2
Pod undocumented
25 2 my ( $self, %args ) = @_;
26 2 my $coderef = $args{Dispatch};
27  
28 3 ▶ return sub {
Subroutine __ANON__: called CC=9 SCAR=23.7
29 3 my ( $self, $date, $p, @args ) = @_;
30 3 ▶ return unless defined $date;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $date 0 3 3
31 3 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
300
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
32  
33 3 my @results = $coderef->($date);
34 3 ▶ return unless @results;
Branch: 1 branch
BranchTrueFalseTotal
unless @results 0 3 3
35 3 ▶ return unless defined $results[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $results[0] 0 3 3
36  
37 3 for my $group (@results) {
38 4 my $parser = $dispatch_data{$class}{$group};
39 4 ▶ die "Unknown parsing group: $class\n" unless defined $parser;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parser 0 4 4
40 4 my $rv = eval { $parser->parse( $self, $date, $p, @args ) };
41 4 ▶ return $rv unless $@ or not defined $rv;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ or not defined $rv 3 1 4
Condition66%2/3
$@ or not defined $rv
l!l&&r!l&&!r
103
MC/DC50%1/2
$@ or not defined $rv
$@ not defined $rv
Truth table66%2/3
A or not(B)
A= $@B= not defined $rv
ABresult
1X1
011
000
42 }
43 0 return;
44 2 };
45 }
46  
47 24 1;
48  
49 # ABSTRACT: Dispatch parsers by group
50  
51 __END__
« Builder/Parser/Quick.pm ↑ Summary Builder/Parser.pm »