FormHandler/Pages.pm

filter: Statementstmt 72.4% 21 / 29 Branchbran 33.3% 4 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 3 totaltotal 55.5% 30 / 54 CC 11 SCAR 30.3
CC
11
Cov
57%
page
33.0
page_index
3.0
BEGIN
1.0
CRAP 20.6
« FormHandler/BuildPages.pm ↑ Summary FormHandler/InitResult.pm »
1 package HTML::FormHandler::Pages;
2 # ABSTRACT: used in Wizard
3 1 $HTML::FormHandler::Pages::VERSION = '0.410002';
4 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 has 'pages' => (
7 traits => ['Array'],
8 isa => 'ArrayRef[HTML::FormHandler::Page]',
9 is => 'rw',
10 8 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
11 1 auto_deref => 1,
12 handles => {
13 all_pages => 'elements',
14 clear_pages => 'clear',
15 push_page => 'push',
16 num_pages => 'count',
17 has_pages => 'count',
18 set_page_at => 'set',
19 get_page => 'get',
20 }
21 );
22  
23 1 has 'page_name_space' => (
24 isa => 'Str|ArrayRef[Str]|Undef',
25 is => 'rw',
26 lazy => 1,
27 builder => 'build_page_name_space',
28 );
29  
30 2 ▶sub build_page_name_space { '' }
Subroutine build_page_name_space: called CC=1 SCAR=0.0
Pod undocumented
31  
32 6 ▶sub page_index {
Subroutine page_index: called CC=3 SCAR=11.0
Pod undocumented
33 6 my ( $self, $name ) = @_;
34 6 my $index = 0;
35 6 for my $page ( $self->all_pages ) {
36 6 ▶ return $index if $page->name eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $page->name eq $name 0 6 6
37 6 $index++;
38 }
39 6 return;
40 }
41  
42 4 ▶sub page {
Subroutine page: called CC=9 SCAR=35.0
Pod undocumented
43 4 my ( $self, $name, $die ) = @_;
44  
45 4 my $index;
46 # if this is a full_name for a compound page
47 # walk through the pages to get to it
48 4 ▶ return undef unless ( defined $name );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 4 4
49 4 ▶ if ( $name =~ /\./ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\./) { } 0 4 4
50 0 my @names = split /\./, $name;
51 0 ▶ my $f = $self->form || $self;
Condition0%0/3
$self->form || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->form || $self
$self->form $self
Truth table0%0/3
A || B
A= $self->formB= $self
ABresult
1X1
011
000
52 0 foreach my $pname (@names) {
53 0 $f = $f->page($pname);
54 0 ▶ return unless $f;
Branch: 1 branch
BranchTrueFalseTotal
unless $f 0 0 0
55 }
56 0 return $f;
57 }
58 else # not a compound name
59 {
60 4 for my $page ( $self->all_pages ) {
61 4 ▶ return $page if ( $page->name eq $name );
Branch: 1 branch
BranchTrueFalseTotal
if $page->name eq $name 4 0 4
62 }
63 }
64 0 ▶ return unless $die;
Branch: 1 branch
BranchTrueFalseTotal
unless $die 0 0 0
65 0 die "Page '$name' not found in '$self'";
66 }
67  
68 1 1;
69  
70 __END__
« FormHandler/BuildPages.pm ↑ Summary FormHandler/InitResult.pm »