SyForm/FormHTML.pm

filter: Statementstmt 85.9% 49 / 57 Branchbran 75.0% 6 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 91.6% 11 / 12 Podpod n/a totaltotal 80.4% 66 / 82 CC 8 SCAR 17.3
CC
8
Cov
81%
_build_html_declare_children
20.0
_build_html_attributes
3.0
_build_html_declare
3.0
CRAP 5.6
« SyForm/ValuesRole/Verify.pm ↑ Summary SyForm/Role/Process.pm »
1 package SyForm::FormHTML;
2 7 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 $SyForm::FormHTML::AUTHORITY = 'cpan:GETTY';
4 }
5 # ABSTRACT: HTML Form
6 7 $SyForm::FormHTML::VERSION = '0.103';
7 7 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use HTML::Declare ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use List::MoreUtils qw( uniq );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use SyForm::ViewField::InputHTML;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 7 with qw(
14 MooX::Traits
15 SyForm::CommonRole::GlobalHTML
16 SyForm::CommonRole::EventHTML
17 );
18  
19 7 our @attributes = qw(
20 action
21 autocomplete
22 enctype
23 method
24 target
25 );
26  
27 7 for my $attribute (@attributes) {
28 35 has $attribute => (
29 is => 'ro',
30 predicate => 1,
31 );
32 }
33  
34 7 my @remote_attributes = uniq(
35 @SyForm::CommonRole::EventHTML::attributes,
36 @SyForm::CommonRole::GlobalHTML::attributes,
37 );
38  
39 7 has submit_attributes => (
40 is => 'lazy',
41 );
42  
43 5 ▶sub _build_submit_attributes {
Subroutine _build_submit_attributes: called CC=1 SCAR=0.0
44 5 my ( $self ) = @_;
45 5 return {};
46 }
47  
48 7 has no_submit => (
49 is => 'lazy',
50 );
51  
52 3 ▶sub _build_no_submit {
Subroutine _build_no_submit: called CC=1 SCAR=0.0
53 3 my ( $self ) = @_;
54 3 return 0;
55 }
56  
57 7 has submit => (
58 is => 'lazy',
59 );
60  
61 6 ▶sub _build_submit {
Subroutine _build_submit: called CC=1 SCAR=0.0
62 6 my ( $self ) = @_;
63 return SyForm::ViewField::InputHTML->new(
64 type => 'submit',
65 6 %{$self->submit_attributes},
66 );
67 }
68  
69 7 has children => (
70 is => 'ro',
71 predicate => 1,
72 );
73  
74 7 has html_attributes => (
75 is => 'lazy',
76 );
77  
78 7 ▶sub _build_html_attributes {
Subroutine _build_html_attributes: called CC=3 SCAR=11.0
79 7 my ( $self ) = @_;
80 7 my %html_attributes = %{$self->data_attributes};
81 7 for my $key (@remote_attributes, @attributes) {
82 630 my $has = 'has_'.$key;
83 630 ▶ $html_attributes{$key} = $self->$key if $self->$has;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$has 8 622 630
84 }
85 7 return { %html_attributes };
86 }
87  
88 7 has html_declare => (
89 is => 'lazy',
90 );
91  
92 7 ▶sub _build_html_declare {
Subroutine _build_html_declare: called CC=3 SCAR=11.0
93 7 my ( $self ) = @_;
94 return FORM {
95 7 ▶ %{$self->html_attributes},
Branch: 1 branch
BranchTrueFalseTotal
$self->has_children ? : 3 4 7
96 _ => [
97 7 ▶ $self->has_children ? ( map { $_->html_declare } @{$self->children} ) : (),
Branch: 1 branch
BranchTrueFalseTotal
$self->no_submit ? : 1 6 7
98 $self->no_submit ? () : ( $self->submit->html_declare ),
99 ],
100 };
101 }
102  
103 7 has html_declare_children => (
104 is => 'lazy',
105 );
106  
107 0 ▶sub _build_html_declare_children {
Subroutine _build_html_declare_children: not called CC=4 SCAR=30.0
108 0 my ( $self ) = @_;
109 0 my @children;
110 0 for my $child (@{$self->children}) {
111 0 ▶ if (!ref $child || $child->$_isa('HTML::Declare')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $child or $child->$SyForm::FormHTML::_isa('HTML::Declare')) { } 0 0 0
Condition0%0/3
not ref $child or $child->$SyForm::FormHTML::_isa("HTML::Declare")
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $child or $child->$SyForm::FormHTML::_isa("HTML::Declare")
not ref $child $child->$SyForm::FormHTML::_isa("HTML::Declare")
Truth table0%0/3
not(A) or B
A= not ref $childB= $child->$SyForm::FormHTML::_isa("HTML::Declare")
ABresult
1X1
011
000
112 0 push @children, $child;
113 } else {
114 0 push @children, $child->html_declare;
115 }
116 }
117 0 return;
118 }
119  
120 7 1;
121  
122 __END__
« SyForm/ValuesRole/Verify.pm ↑ Summary SyForm/Role/Process.pm »