Tested/Value/Array.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 77.2% 17 / 22 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod 66.6% 2 / 3 totaltotal 82.2% 65 / 79 CC 14 SCAR 18.7
CC
14
Cov
86%
transform_value
10.5
new
4.1
seal_value
2.1
CRAP 6.5
« Tested/Test/Request.pm ↑ Summary Tested/Test/Value.pm »
1 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package HTML::Tested::Value::Array;
5 6 ▶use base 'HTML::Tested::Value';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 14 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
9 14 my $self = shift()->SUPER::new(@_);
10 14 my $opts = $self->options;
11 14 ▶ while (my ($n, $v) = each %$opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$opts) 12 14 26
12 12 ▶ next unless ref($v) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $v eq "HASH" 10 2 12
13 2 ▶ my $dto = $v->{is_datetime} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $dto = $v->{"is_datetime"} or next 0 2 2
14 0 $self->setup_datetime_option($dto, $v);
15 }
16 14 return $self;
17 }
18  
19 44 ▶sub transform_value {
Subroutine transform_value: called CC=10 SCAR=23.5
Pod undocumented
20 44 my ($self, $caller, $val, $n) = @_;
21 44 ▶ confess "Invalid non-array value: seal_value"
Branch: 1 branch
BranchTrueFalseTotal
unless $val and ref $val eq "ARRAY" 0 44 44
Condition33%1/3
$val and ref $val eq "ARRAY"
!ll&&!rl&&r
0044
MC/DC0%0/2
$val and ref $val eq "ARRAY"
$val ref $val eq "ARRAY"
Truth table33%1/3
A and B
A= $valB= ref $val eq "ARRAY"
ABresult
0X0
100
111
22 unless $val && ref($val) eq 'ARRAY';
23 44 my $opts = $self->options;
24 44 my @res;
25 44 ▶ for (my $i = 0; $i < @$val; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$val) 103 44 147
26 103 my $nopts = $opts->{$i};
27 103 ▶ $self->{_options} = $nopts if $nopts;
Branch: 1 branch
BranchTrueFalseTotal
if $nopts 9 94 103
28 103 my $v = $val->[$i];
29 103 my $dtfs = $caller->ht_get_widget_option($n, "is_datetime");
30 103 ▶ $v = $dtfs->format_datetime($v) if ($v && $dtfs);
Branch: 1 branch
BranchTrueFalseTotal
if $v and $dtfs 0 103 103
Condition66%2/3
$v and $dtfs
!ll&&!rl&&r
8950
MC/DC0%0/2
$v and $dtfs
$v $dtfs
Truth table66%2/3
A and B
A= $vB= $dtfs
ABresult
0X0
100
111
31 103 ▶ $v = $self->seal_value($v, $caller)
Branch: 1 branch
BranchTrueFalseTotal
if $caller->ht_get_widget_option($n, "is_sealed") 20 83 103
32 if $caller->ht_get_widget_option($n, "is_sealed");
33 103 ▶ $v = $self->encode_value($v, $caller)
Branch: 1 branch
BranchTrueFalseTotal
unless $caller->ht_get_widget_option($n, "is_trusted") 103 0 103
34 if !($caller->ht_get_widget_option($n, "is_trusted"));
35 103 push @res, $v;
36 103 ▶ $self->{_options} = $opts if $nopts;
Branch: 1 branch
BranchTrueFalseTotal
if $nopts 9 94 103
37 }
38 44 return \@res;
39 }
40  
41 20 ▶sub seal_value {
Subroutine seal_value: called CC=2 SCAR=7.2
Pod documented
42 20 my ($self, $val, $caller) = @_;
43 20 ▶ return $self->options->{isnt_sealed} ? $val
Branch: 1 branch
BranchTrueFalseTotal
$self->options->{'isnt_sealed'} ? : 0 20 20
44 : $self->SUPER::seal_value($val, $caller);
45 }
46  
47 6 1;
« Tested/Test/Request.pm ↑ Summary Tested/Test/Value.pm »