lib/HTML/FormFu/Constraint/Email.pm

filter: Statementstmt 100% 34 / 34 Branchbran 83.3% 10 / 12 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 91.6% 55 / 60 CC 11 SCAR 21.3
CC
11
Cov
94%
constrain_value
11.1
BEGIN
1.0
BEGIN
1.0
CRAP 8.4
« lib/HTML/FormFu/OutputProcessor/StripWhitespace.pm ↑ Summary lib/HTML/FormFu/Deflator/CompoundSplit.pm »
1 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::Email;
4 7 $HTML::FormFu::Constraint::Email::VERSION = '2.09';
5 # ABSTRACT: Email Address Constraint
6  
7 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 extends 'HTML::FormFu::Constraint';
11  
12 7 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 7 has options => ( is => 'rw', traits => ['Chained'] );
15  
16 12 ▶sub constrain_value {
Subroutine constrain_value: called CC=11 SCAR=24.1
Pod undocumented
17 12 my ( $self, $value ) = @_;
18  
19 12 ▶ return 1 if !defined $value || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 1 11 12
Condition66%2/3
not defined $value or $value eq ""
l!l&&r!l&&!r
0111
MC/DC50%1/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table66%2/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
20  
21 11 my %options = ( -address => $value );
22  
23 11 ▶ if ( defined $self->options ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->options) 5 6 11
24  
25 5 ▶ if ( ref $self->options eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->options eq 'ARRAY') { } 1 4 5
elsif (ref $self->options eq 'HASH') { } 3 1 4
26  
27 1 for my $foo ( @{ $self->options } ) {
28 1 ▶ next if $foo eq 'address';
Branch: 1 branch
BranchTrueFalseTotal
if $foo eq "address" 0 1 1
29 1 $options{ '-' . $foo } = 1;
30 }
31  
32 }
33 elsif ( ref $self->options eq 'HASH' ) {
34  
35 3 for my $foo ( keys %{ $self->options } ) {
36 3 ▶ next if $foo eq 'address';
Branch: 1 branch
BranchTrueFalseTotal
if $foo eq "address" 0 3 3
37 3 $options{ '-' . $foo } = $self->options->{$foo};
38 }
39  
40 }
41 else {
42  
43 1 $options{ '-' . $self->options } = 1;
44  
45 }
46  
47 }
48  
49 11 ▶ my $validated_address = ( Email::Valid->address(%options) // '' );
Condition100%2/2
"Email::Valid"->address(%options) // ""
l!l
74
MC/DC100%1/1
"Email::Valid"->address(%options) // ""
"Email::Valid"->address(%options)
Truth table100%2/2
A
A= "Email::Valid"->address(%options)
Aresult
11
00
50 11 my $ok = $value eq $validated_address;
51  
52 11 return $ok;
53 }
54  
55 7 __PACKAGE__->meta->make_immutable;
56  
57 7 1;
58  
59 __END__
« lib/HTML/FormFu/OutputProcessor/StripWhitespace.pm ↑ Summary lib/HTML/FormFu/Deflator/CompoundSplit.pm »