FormHandler/Field/IntRange.pm

filter: Statementstmt 100% 23 / 23 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 83.3% 30 / 36 CC 6 SCAR 16.2
CC
6
Cov
87%
build_options
6.4
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« FormHandler/Field/Captcha.pm ↑ Summary FormHandler/Render/Util.pm »
1 package HTML::FormHandler::Field::IntRange;
2 # ABSTRACT: integer range in select list
3 3 $HTML::FormHandler::Field::IntRange::VERSION = '0.410002';
4 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 extends 'HTML::FormHandler::Field::Select';
6  
7 3 has 'label_format' => ( isa => 'Str', is => 'rw', default => '%d' );
8 3 has '+range_start' => ( default => 1 );
9 3 has '+range_end' => ( default => 10 );
10  
11 10 ▶sub build_options {
Subroutine build_options: called CC=6 SCAR=18.6
Pod undocumented
12 10 my $self = shift;
13  
14 10 my $start = $self->range_start;
15 10 my $end = $self->range_end;
16  
17 10 for ( $start, $end ) {
18 20 ▶ die "Both range_start and range_end must be defined" unless defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 20 20
19 20 ▶ die "Integer ranges must be integers" unless /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^\d+$/ 0 20 20
20 }
21  
22 10 ▶ die "range_start must be less than range_end" unless $start < $end;
Branch: 1 branch
BranchTrueFalseTotal
unless $start < $end 0 10 10
23  
24 10 ▶ my $format = $self->label_format || die 'IntRange needs label_format';
Condition50%1/2
$self->label_format || die('IntRange needs label_format')
l!l
100
MC/DC0%0/1
$self->label_format || die('IntRange needs label_format')
$self->label_format
Truth table50%1/2
A
A= $self->label_format
Aresult
11
00
25  
26 10 return [ map { { value => $_, label => sprintf( $format, $_ ) } }
27 $self->range_start .. $self->range_end ];
28 }
29  
30  
31 3 __PACKAGE__->meta->make_immutable;
32 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 1;
34  
35 __END__
« FormHandler/Field/Captcha.pm ↑ Summary FormHandler/Render/Util.pm »