blib/lib/CGI/Application/Plugin/FormValidator/Simple.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 43.1% 22 / 51 CC 6 SCAR 23.1
CC
6
Cov
40%
form
20.0
validator
12.0
BEGIN
1.0
CRAP 10.1
↑ Summary
1 package CGI::Application::Plugin::FormValidator::Simple;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use FormValidator::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9  
10 1 @EXPORT = qw(
11 validator
12 form
13 );
14 1 ▶sub import { goto &Exporter::import }
Subroutine import: called CC=1 SCAR=0.0
15  
16 1 $VERSION = '0.03';
17  
18 0 ▶sub validator {
Subroutine validator: not called CC=3 SCAR=24.8
Pod undocumented
19 0 my $self = shift;
20 0 my %params = @_;
21  
22 0 my $plugins = $params{plugins};
23 0 ▶ FormValidator::Simple->import(@$plugins) if $plugins;
Branch: 1 branch
BranchTrueFalseTotal
if $plugins 0 0 0
24  
25 0 my $options = $params{options};
26 0 $self->{validator} = FormValidator::Simple->new(%$options);
27
28 0 ▶ if (exists $params{messages}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params{"messages"}) 0 0 0
29 0 FormValidator::Simple->set_messages($params{messages});
30 }
31
32 0 return $self->{validator};
33 }
34  
35  
36 0 ▶sub form {
Subroutine form: not called CC=4 SCAR=30.0
Pod undocumented
37 0 my $self = shift;
38 0 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 0 0 0
39 0 ▶ my $form = $_[1] ? [@_] : $_[0];
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 0 0
40 0 ▶ $self->validator() unless $self->{validator};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"validator"} 0 0 0
41 0 $self->{form} = $self->{validator}->check($self->query, $form);
42 }
43 0 return $self->{form};
44 }
45  
46  
47 1 1;
48 __END__
↑ Summary