Simple/Data.pm

filter: Statementstmt 38.2% 13 / 34 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 3 totaltotal 28.8% 17 / 59 CC 9 SCAR 29.5
CC
9
Cov
27%
_init
42.0
param
12.0
has_key
6.0
CRAP 19.1
« Simple/Results.pm ↑ Summary Simple/Constraint.pm »
1 package FormValidator::Simple::Data;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use FormValidator::Simple::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use FormValidator::Simple::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
8 0 my $class = shift;
9 0 my $self = bless { }, $class;
10 0 $self->_init(@_);
11 0 return $self;
12 }
13  
14 0 ▶sub _init {
Subroutine _init: not called CC=6 SCAR=37.4
15 0 my ($self, $input) = @_;
16 0 $self->{_records} = {};
17 0 my $errmsg = qq/Set input data as a hashref or object that has the method 'param()'./;
18 0 ▶ if ( Scalar::Util::blessed($input) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($input)) { } 0 0 0
elsif (ref $input eq 'HASH') { } 0 0 0
19 0 ▶ unless ( $input->can('param') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($input->can("param")) 0 0 0
20 0 FormValidator::Simple::Exception->throw($errmsg);
21 }
22 0 foreach my $key ( $input->param ) {
23 0 my @v = $input->param($key);
24 0 ▶ $self->{_records}{$key} = scalar(@v) > 1 ? \@v : $v[0];
Branch: 1 branch
BranchTrueFalseTotal
scalar @v > 1 ? : 0 0 0
25 }
26 }
27 elsif ( ref $input eq 'HASH' ) {
28 0 $self->{_records} = $input;
29 }
30 else {
31 0 FormValidator::Simple::Exception->throw($errmsg);
32 }
33 }
34  
35 0 ▶sub has_key {
Subroutine has_key: not called CC=2 SCAR=17.9
Pod undocumented
36 0 my ($self, $key) = @_;
37 0 ▶ return exists $self->{_records}{$key} ? TRUE : FALSE;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'_records'}{$key} ? : 0 0 0
38 }
39  
40 0 ▶sub param {
Subroutine param: not called CC=3 SCAR=24.8
Pod undocumented
41 0 my ($self, $keys) = @_;
42 my @values = map {
43 0 exists $self->{_records}{$_}
44 0 ▶ ? $self->{_records}{$_}
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'_records'}{$_} ? : 0 0 0
45 : ''
46 ;
47 } @$keys;
48 0 ▶ return wantarray ? @values : \@values;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
49 }
50  
51 9 1;
52 __END__
« Simple/Results.pm ↑ Summary Simple/Constraint.pm »