blib/lib/HTML/Widgets/NavMenu/Iterator/Html.pm

filter: Statementstmt 100% 49 / 49 Branchbran 100% 12 / 12 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 13 / 13 Podpod 100% 5 / 5 totaltotal 100% 84 / 84 SCAR 20.8
CC
8
Cov
100%
node_start
3.0
node_end
3.0
_end_regular
3.0
CRAP 8.0
« blib/lib/HTML/Widgets/NavMenu/Iterator/Base.pm ↑ Summary blib/lib/HTML/Widgets/NavMenu/Tree/Iterator.pm »
1 package HTML::Widgets::NavMenu::Iterator::Html;
2 19 $HTML::Widgets::NavMenu::Iterator::Html::VERSION = '1.0902';
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 19 ▶use HTML::Widgets::NavMenu::Iterator::Html::Item ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 19 ▶use parent qw(HTML::Widgets::NavMenu::Iterator::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 19 ▶use HTML::Widgets::NavMenu::EscapeHtml qw/ escape_html /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub _construct_new_item
14 {
15 979 ▶ my $self = shift;
Subroutine _construct_new_item: called CC=1 SCAR=0.0
16 979 my $args = shift;
17  
18 979 return HTML::Widgets::NavMenu::Iterator::Html::Item->new( $args, );
19 }
20  
21  
22 sub _is_top_separator
23 {
24 494 ▶ return $_[0]->top->{_node}->{separator};
Subroutine _is_top_separator: called CC=1 SCAR=0.0
25 }
26  
27 sub node_start
28 {
29 297 ▶ my $self = shift;
Subroutine node_start: called CC=3 SCAR=11.0
Pod documented
30  
31 297 ▶ if ( $self->{_is_root} )
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_is_root'}) { } 50 247 297
elsif ($self->_is_top_separator) { } 3 244 247
32 {
33 50 return $self->_start_root();
34 }
35 elsif ( $self->_is_top_separator() )
36 {
37 # _start_sep() is short for start_separator().
38 3 return $self->_start_sep();
39 }
40 else
41 {
42 244 return $self->_start_regular();
43 }
44 }
45  
46  
47 sub node_end
48 {
49 297 ▶ my $self = shift;
Subroutine node_end: called CC=3 SCAR=11.0
Pod documented
50  
51 297 ▶ if ( $self->{_is_root} )
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_is_root'}) { } 50 247 297
elsif ($self->_is_top_separator) { } 3 244 247
52 {
53 50 return $self->end_root();
54 }
55 elsif ( $self->_is_top_separator() )
56 {
57 3 return $self->_end_sep();
58 }
59 else
60 {
61 244 return $self->_end_regular();
62 }
63 }
64  
65  
66 sub end_root
67 {
68 50 ▶ my $self = shift;
Subroutine end_root: called CC=1 SCAR=0.0
Pod documented
69  
70 50 $self->_add_tags("</ul>");
71 }
72  
73 sub _end_regular
74 {
75 236 ▶ my $self = shift;
Subroutine _end_regular: called CC=3 SCAR=11.0
76 236 ▶ if ( $self->top()->_num_subs() && $self->_is_expanded() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->top->_num_subs and $self->_is_expanded) 51 185 236
Condition100%3/3
$self->top->_num_subs and $self->_is_expanded
!ll&&!rl&&r
1701551
MC/DC100%2/2
$self->top->_num_subs and $self->_is_expanded
$self->top->_num_subs $self->_is_expanded
Truth table100%3/3
A and B
A= $self->top->_num_subsB= $self->_is_expanded
ABresult
0X0
100
111
77 {
78 51 $self->_add_tags("</ul>");
79 }
80 236 $self->_add_tags("</li>");
81 }
82  
83  
84 sub node_should_recurse
85 {
86 544 ▶ my $self = shift;
Subroutine node_should_recurse: called CC=1 SCAR=0.0
Pod documented
87 544 return $self->_is_expanded();
88 }
89  
90  
91 # Get the HTML <a href=""> tag.
92 #
93 sub get_a_tag
94 {
95 215 ▶ my $self = shift;
Subroutine get_a_tag: called CC=2 SCAR=6.9
Pod documented
96 215 my $item = $self->top();
97 215 my $node = $item->_node;
98  
99 215 my $tag = "<a";
100 215 my $title = $node->title;
101  
102 215 $tag .= " href=\""
103 . escape_html( $self->nav_menu()->_get_url_to_item($item) ) . "\"";
104 215 ▶ if ( defined($title) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $title) 71 144 215
105 {
106 71 $tag .= " title=\"$title\"";
107 }
108 215 $tag .= ">" . $node->text() . "</a>";
109 215 return $tag;
110 }
111  
112  
113 19 1;
114  
115 __END__
« blib/lib/HTML/Widgets/NavMenu/Iterator/Base.pm ↑ Summary blib/lib/HTML/Widgets/NavMenu/Tree/Iterator.pm »