SyForm/ViewField/LabelHTML.pm

filter: Statementstmt 100% 30 / 30 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 95.1% 39 / 41 CC 6 SCAR 13.9
CC
6
Cov
94%
_build_html_declare
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« SyForm/Exception/Role/WithOriginalError.pm ↑ Summary SyForm/ViewField.pm »
1 package SyForm::ViewField::LabelHTML;
2 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 $SyForm::ViewField::LabelHTML::AUTHORITY = 'cpan:GETTY';
4 }
5 3 $SyForm::ViewField::LabelHTML::VERSION = '0.103';
6 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use List::MoreUtils qw( uniq );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use HTML::Declare ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 with qw(
11 MooX::Traits
12 SyForm::CommonRole::GlobalHTML
13 );
14  
15 3 has label => (
16 is => 'ro',
17 required => 1,
18 );
19  
20 3 my @own_attributes = qw( for );
21  
22 3 for my $attribute (@own_attributes, qw( errors )) {
23 6 has $attribute => (
24 is => 'ro',
25 predicate => 1,
26 );
27 }
28  
29 3 has html_declare => (
30 is => 'lazy',
31 );
32  
33 13 ▶sub _build_html_declare {
Subroutine _build_html_declare: called CC=6 SCAR=18.0
34 13 my ( $self ) = @_;
35 13 my %html_attributes = %{$self->data_attributes};
36 13 for my $key (@SyForm::CommonRole::GlobalHTML::attributes) {
37 208 my $has = 'has_'.$key;
38 208 ▶ $html_attributes{$key} = $self->$key if $self->$has;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$has 0 208 208
39 }
40 13 for my $key (@own_attributes) {
41 13 my $has = 'has_'.$key;
42 13 ▶ $html_attributes{$key} = $self->$key if $self->$has;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$has 13 0 13
43 }
44 $html_attributes{_} = [
45 $self->label,
46 $self->has_errors ? (
47 13 ▶ map { EM { _ => $_->message } } @{$self->errors}
Branch: 1 branch
BranchTrueFalseTotal
$self->has_errors ? : 2 11 13
48 ) : (),
49 ],
50 return LABEL { %html_attributes };
51 }
52  
53 3 1;
54  
55 __END__
« SyForm/Exception/Role/WithOriginalError.pm ↑ Summary SyForm/ViewField.pm »