FormHandler/TraitFor/Types.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 93.4% 43 / 46 CC 5 SCAR 6.5
CC
5
Cov
95%
__ANON__
3.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.9
« FormHandler/Widget/Field/Role/HTMLAttributes.pm ↑ Summary FormHandler/Result.pm »
1 package HTML::FormHandler::TraitFor::Types;
2 # ABSTRACT: types used internally in FormHandler
3 149 $HTML::FormHandler::TraitFor::Types::VERSION = '0.410002';
4 149 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 149 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 149 subtype 'HFH::ArrayRefStr'
8 => as 'ArrayRef[Str]';
9  
10 coerce 'HFH::ArrayRefStr'
11 => from 'Str'
12 297 ▶ => via {
Subroutine __ANON__: called CC=2 SCAR=6.9
13 297 ▶ if( length $_ ) { return [$_] };
Branch: 1 branch
BranchTrueFalseTotal
if (length $_) 43 254 297
14 254 return [];
15 149 };
16  
17 coerce 'HFH::ArrayRefStr'
18 => from 'Undef'
19 0 ▶ => via { return []; };
Subroutine __ANON__: not called CC=1 SCAR=1.2
20  
21 149 subtype 'HFH::SelectOptions'
22 => as 'ArrayRef[HashRef]';
23  
24 coerce 'HFH::SelectOptions'
25 => from 'ArrayRef[Str]'
26 123 ▶ => via {
Subroutine __ANON__: called CC=3 SCAR=11.0
27 123 my @options = @$_;
28 123 ▶ die "Options array must contain an even number of elements"
Branch: 1 branch
BranchTrueFalseTotal
if @options % 2 0 123 123
29 if @options % 2;
30 123 my $opts;
31 123 ▶ push @{$opts}, { value => shift @options, label => shift @options } while @options;
Branch: 1 branch
BranchTrueFalseTotal
@options and do { push @{$opts;}, {"value", shift @options, "label", shift @options} } 395 123 518
32 123 return $opts;
33 149 };
34  
35 coerce 'HFH::SelectOptions'
36 => from 'ArrayRef[ArrayRef]'
37 8 ▶ => via {
Subroutine __ANON__: called CC=2 SCAR=6.9
38 8 my @options = @{ $_[0][0] };
39 8 my $opts;
40 8 push @{$opts}, { value => $_, label => $_ } foreach @options;
41 8 return $opts;
42 149 };
43  
44 149 ▶no Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 149 1;
46  
47 __END__
« FormHandler/Widget/Field/Role/HTMLAttributes.pm ↑ Summary FormHandler/Result.pm »