lib/Mail/AuthenticationResults/Token/String.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 18 / 18 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 68 / 68 CC 11 SCAR 20.6
CC
11
Cov
100%
parse
11.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.9
« lib/Mail/AuthenticationResults/FoldableHeader.pm ↑ Summary lib/Mail/AuthenticationResults/Header/Comment.pm »
1 package Mail::AuthenticationResults::Token::String;
2 # ABSTRACT: Class for modelling AuthenticationResults Header parts detected as strings
3  
4 32 require 5.008;
5 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 32 our $VERSION = '2.20261029'; # VERSION
8 32 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 32 ▶use base 'Mail::AuthenticationResults::Token';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 97813 ▶sub is {
Subroutine is: called CC=1 SCAR=0.0
Pod documented
14 97813 my ( $self ) = @_;
15 97813 return 'string';
16 }
17  
18 28657 ▶sub parse {
Subroutine parse: called CC=11 SCAR=24.0
Pod documented
19 28657 my ($self) = @_;
20  
21 28657 my $header = $self->{ 'header' };
22 28657 my $value = q{};
23  
24 28657 ▶ croak 'Not a string' if $header =~ /^"/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^"/ 1 28656 28657
25 28656 ▶ croak 'Not a string' if $header =~ /^\(/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^\(/ 1 28655 28656
26  
27 # Parse differently if we are post assignment (we are a value) or not (we are likely a key or key part)
28 28655 my $is_value = 0;
29 28655 my $is_first = 0;
30 28655 ▶ if ( exists ( $self->{ 'args' }->{ 'last_non_comment_type' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'args'}{'last_non_comment_type'}) { } 28592 63 28655
31 28592 ▶ if ( $self->{ 'args' }->{ 'last_non_comment_type' }->is() eq 'assignment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"args"}{"last_non_comment_type"}->is eq "assignment") 17658 10934 28592
32 17658 ▶ if ( $self->{ 'args' }->{ 'last_non_comment_type' }->value() eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"args"}{"last_non_comment_type"}->value eq "=") 10909 6749 17658
33 10909 $is_value = 1;
34 }
35 }
36 }
37 else {
38 63 $is_first = 1;
39 }
40  
41 28655 ▶ if ( $is_value || $is_first ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_value or $is_first) { } 10972 17683 28655
Condition100%3/3
$is_value or $is_first
l!l&&r!l&&!r
109096317683
MC/DC100%2/2
$is_value or $is_first
$is_value $is_first
Truth table100%3/3
A or B
A= $is_valueB= $is_first
ABresult
1X1
011
000
42 10972 ▶ $value = $1 if $header =~ /^([^\s;]+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^([^\s;]+)/ 10969 3 10972
43 }
44 else {
45 17683 ▶ $value = $1 if $header =~ /^([^\s;"(=\/.]+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ m[^([^\s;"(=/.]+)] 17680 3 17683
46 }
47  
48 28655 ▶ croak 'Not a string' if $value eq q{};
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 6 28649 28655
49  
50 28649 $header = substr( $header, length $value );
51  
52 28649 $self->{ 'value' } = $value;
53 28649 $self->{ 'header' } = $header;
54  
55 28649 return;
56 }
57  
58 32 1;
59  
60 __END__
« lib/Mail/AuthenticationResults/FoldableHeader.pm ↑ Summary lib/Mail/AuthenticationResults/Header/Comment.pm »