FormHandler/Field/Multiple.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 92.3% 36 / 39 CC 4 SCAR 10.0
CC
4
Cov
97%
default_sort_options
4.0
BEGIN
1.0
__ANON__
1.0
CRAP 2.7
« FormHandler/Field/AddElement.pm ↑ Summary FormHandler/Field/PrimaryKey.pm »
1 package HTML::FormHandler::Field::Multiple;
2 # ABSTRACT: multiple select list
3 19 $HTML::FormHandler::Field::Multiple::VERSION = '0.410002';
4 19 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 extends 'HTML::FormHandler::Field::Select';
6  
7  
8 19 has '+multiple' => ( default => 1 );
9 19 has '+size' => ( default => 5 );
10 31 ▶has '+sort_options_method' => ( default => sub { \&default_sort_options } );
Subroutine __ANON__: called CC=1 SCAR=0.0
11  
12 48 ▶sub default_sort_options {
Subroutine default_sort_options: called CC=4 SCAR=13.9
Pod undocumented
13 48 my ( $self, $options ) = @_;
14  
15 48 ▶ return $options unless scalar @$options && defined $self->value;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$options and defined $self->value 4 44 48
Condition66%2/3
scalar @$options and defined $self->value
!ll&&!rl&&r
4044
MC/DC50%1/2
scalar @$options and defined $self->value
scalar @$options defined $self->value
Truth table66%2/3
A and B
A= scalar @$optionsB= defined $self->value
ABresult
0X0
100
111
16 44 my $value = $self->deflate($self->value);
17 44 ▶ return $options unless scalar @$value;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$value 38 6 44
18 # This places the currently selected options at the top of the list
19 # Makes the drop down lists a bit nicer
20 6 my %selected = map { $_ => 1 } @$value;
21 6 my @out = grep { $selected{ $_->{value} } } @$options;
22 6 push @out, grep { !$selected{ $_->{value} } } @$options;
23 6 return \@out;
24 }
25  
26 19 __PACKAGE__->meta->make_immutable;
27 19 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 19 1;
29  
30 __END__
« FormHandler/Field/AddElement.pm ↑ Summary FormHandler/Field/PrimaryKey.pm »