I18N/Util.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 88.0% 44 / 50 CC 7 SCAR 15.2
CC
7
Cov
90%
try_load_class
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.6
↑ Summary Middleware/I18N.pm »
1 package Plack::I18N::Util;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our @EXPORT_OK = qw(try_load_class);
9  
10 4 ▶use Plack::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 48 ▶sub try_load_class {
Subroutine try_load_class: called CC=7 SCAR=19.7
Pod documented
13 48 my ($class) = @_;
14  
15 48 my $path = (join '/', split /::/, $class) . '.pm';
16  
17 48 ▶ return $class if exists $INC{$path} && defined $INC{$path};
Branch: 1 branch
BranchTrueFalseTotal
if exists $INC{$path} and defined $INC{$path} 0 48 48
Condition33%1/3
exists $INC{$path} and defined $INC{$path}
!ll&&!rl&&r
4800
MC/DC0%0/2
exists $INC{$path} and defined $INC{$path}
exists $INC{$path} defined $INC{$path}
Truth table33%1/3
A and B
A= exists $INC{$path}B= defined $INC{$path}
ABresult
0X0
100
111
18  
19 {
20 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 48 for (keys %{"$class\::"}) {
22 207 ▶ return $class if defined &{"$class\::$_"};
Branch: 1 branch
BranchTrueFalseTotal
if defined &{"${class}::$_";} 39 168 207
23 }
24 }
25  
26 eval {
27 9 Plack::Util::load_class($class);
28 9 ▶ } || do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { Plack::Util::load_class($class) } } or do { my $e = $@; die $e unless $@ =~ /Can't locate $path in \@INC/; return } 1 8 9
29 8 my $e = $@;
30  
31 8 ▶ die $e unless $@ =~ m/Can't locate $path in \@INC/;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ =~ /Can't locate $path in \@INC/ 0 8 8
32  
33 8 return;
34 };
35 }
36  
37 4 1;
38 __END__
↑ Summary Middleware/I18N.pm »