blib/lib/FormValidator/Lite/Upload.pm

filter: Statementstmt 91.6% 33 / 36 Branchbran 62.5% 10 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 83.3% 50 / 60 SCAR 22.4
CC
9
Cov
83%
new
8.6
_load
3.0
BEGIN
1.0
CRAP 9.4
« blib/lib/FormValidator/Lite/Constraint/Time.pm ↑ Summary Build »
1 package FormValidator::Lite::Upload;
2 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 30 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 30 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 {
8 30 my %cache;
9 sub _load {
10 11 ▶ my $pkg = shift;
Subroutine _load: called CC=3 SCAR=11.0
11 11 ▶ unless ($cache{$pkg}++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cache{$pkg}++) 3 8 11
12 3 ▶ eval "use $pkg"; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶ Carp::croak($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
14 }
15 11 $pkg;
16 }
17 }
18  
19  
20 30 sub new {
21 12 ▶ my ($self, $q, $name) = @_;
Subroutine new: called CC=7 SCAR=21.5
Pod undocumented
22 12 ▶ Carp::croak("missing parameter \$name") unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 12 12
23 12 ▶ Carp::croak("\$q is not a object") unless blessed $q;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($q) 0 12 12
24  
25 12 my $pkg = do {
26 12 ▶ if ($q->isa('CGI')) {
Branch: 3 branches
BranchTrueFalseTotal
if ($q->isa('CGI')) { } 11 1 12
elsif ($q->isa('HTTP::Engine::Request')) { } 0 1 1
elsif ($q->isa('Plack::Request')) { } 0 1 1
27 11 'CGI';
28 } elsif ($q->isa('HTTP::Engine::Request')) {
29 0 'HTTPEngine';
30 } elsif ($q->isa('Plack::Request')) {
31 0 'PlackRequest';
32 } else {
33 1 ▶ if ($q->can('upload')){ # duck typing
Branch: 1 branch
BranchTrueFalseTotal
if ($q->can('upload')) { } 1 0 1
34 # this feature is needed by HTML::Shakan or other form validation libraries
35 1 return $q->upload($name); # special case :)
36 } else {
37 0 die "unknown request type: $q";
38 }
39 }
40 };
41 11 $pkg = 'FormValidator::Lite::Upload::' . $pkg;
42  
43 11 _load($pkg)->new($q, $name);
44 }
45  
46 30 1;
« blib/lib/FormValidator/Lite/Constraint/Time.pm ↑ Summary Build »