lib/Mail/AuthenticationResults/Token/String.pm

filter: Statementstmt 100% 44 / 44 Branchbran 89.2% 25 / 28 Conditioncond 60.0% 18 / 30 MC/DCmcdc 33.3% 5 / 15 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 80.0% 100 / 125 SCAR 33.0
CC
25
Cov
85%
parse
28.4
BEGIN
1.0
BEGIN
1.0
CRAP 27.0
« lib/Mail/AuthenticationResults/Header.pm ↑ Summary lib/Mail/AuthenticationResults/FoldableHeader.pm »
1 package Mail::AuthenticationResults::Token::String;
2 # ABSTRACT: Class for modelling AuthenticationResults Header parts detected as strings
3  
4 30 require 5.008;
5 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 our $VERSION = '2.20230112'; # VERSION
8 30 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 30 ▶use base 'Mail::AuthenticationResults::Token';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 sub is {
14 4346 ▶ my ( $self ) = @_;
Subroutine is: called CC=1 SCAR=0.0
Pod documented
15 4346 return 'string';
16 }
17  
18 sub parse {
19 651 ▶ my ($self) = @_;
Subroutine parse: called CC=25 SCAR=33.5
Pod documented
20  
21 651 my $header = $self->{ 'header' };
22 651 my $value = q{};
23  
24 651 ▶ croak 'Not a string' if $header =~ /^"/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^"/ 1 650 651
25 650 ▶ croak 'Not a string' if $header =~ /^\(/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^\(/ 1 649 650
26  
27 # Parse differently if we are post assignment (we are a value) or not (we are likely a key or key part)
28 649 my $is_value = 0;
29 649 my $is_first = 0;
30 649 ▶ if ( exists ( $self->{ 'args' }->{ 'last_non_comment_type' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'args'}{'last_non_comment_type'}) { } 589 60 649
31 589 ▶ if ( $self->{ 'args' }->{ 'last_non_comment_type' }->is() eq 'assignment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"args"}{"last_non_comment_type"}->is eq "assignment") 324 265 589
32 324 ▶ if ( $self->{ 'args' }->{ 'last_non_comment_type' }->value() eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"args"}{"last_non_comment_type"}->value eq "=") 241 83 324
33 241 $is_value = 1;
34 }
35 }
36 }
37 else {
38 60 $is_first = 1;
39 }
40  
41 649 ▶ while ( length $header > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $header > 0) 5298 35 5333
42 5298 my $first = substr( $header,0,1 );
43 5298 ▶ last if $first =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $first =~ /\s/ 205 5093 5298
44 5093 ▶ last if $first eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $first eq ";" 97 4996 5093
45 4996 ▶ last if $first eq '"' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "\"" and not $is_value and not $is_first 0 4996 4996
Condition33%2/6
$first eq "\"" and not $is_value and not $is_first
!ll&&!rl&&r
499600
$first eq "\"" and not $is_value
!ll&&!rl&&r
499600
MC/DC0%0/3
$first eq "\"" and not $is_value and not $is_first
$first eq "\"" not $is_value not $is_first
Truth table25%1/4
A and not(B) and not(C)
A= $first eq "\""B= not $is_valueC= not $is_first
ABCresult
0XX0
10X0
1100
1111
46 4996 ▶ last if $first eq '(' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "(" and not $is_value and not $is_first 0 4996 4996
Condition33%2/6
$first eq "(" and not $is_value and not $is_first
!ll&&!rl&&r
499600
$first eq "(" and not $is_value
!ll&&!rl&&r
499600
MC/DC0%0/3
$first eq "(" and not $is_value and not $is_first
$first eq "(" not $is_value not $is_first
Truth table25%1/4
A and not(B) and not(C)
A= $first eq "("B= not $is_valueC= not $is_first
ABCresult
0XX0
10X0
1100
1111
47 4996 ▶ last if $first eq '=' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "=" and not $is_value and not $is_first 236 4760 4996
Condition83%5/6
$first eq "=" and not $is_value and not $is_first
!ll&&!rl&&r
47600236
$first eq "=" and not $is_value
!ll&&!rl&&r
47591236
MC/DC66%2/3
$first eq "=" and not $is_value and not $is_first
$first eq "=" not $is_value not $is_first
Truth table75%3/4
A and not(B) and not(C)
A= $first eq "="B= not $is_valueC= not $is_first
ABCresult
0XX0
10X0
1100
1111
48 4760 ▶ last if $first eq '/' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "/" and not $is_value and not $is_first 0 4760 4760
Condition50%3/6
$first eq "/" and not $is_value and not $is_first
!ll&&!rl&&r
476000
$first eq "/" and not $is_value
!ll&&!rl&&r
475730
MC/DC0%0/3
$first eq "/" and not $is_value and not $is_first
$first eq "/" not $is_value not $is_first
Truth table50%2/4
A and not(B) and not(C)
A= $first eq "/"B= not $is_valueC= not $is_first
ABCresult
0XX0
10X0
1100
1111
49 4760 ▶ last if $first eq '.' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "." and not $is_value and not $is_first 76 4684 4760
Condition100%6/6
$first eq "." and not $is_value and not $is_first
!ll&&!rl&&r
457710776
$first eq "." and not $is_value
!ll&&!rl&&r
4463114183
MC/DC100%3/3
$first eq "." and not $is_value and not $is_first
$first eq "." not $is_value not $is_first
Truth table100%4/4
A and not(B) and not(C)
A= $first eq "."B= not $is_valueC= not $is_first
ABCresult
0XX0
10X0
1100
1111
50  
51 4684 $value .= $first;
52 4684 $header = substr( $header,1 );
53 }
54  
55 649 ▶ croak 'Not a string' if $value eq q{};
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 5 644 649
56  
57 644 $self->{ 'value' } = $value;
58 644 $self->{ 'header' } = $header;
59  
60 644 return;
61 }
62  
63 30 1;
64  
65 __END__
« lib/Mail/AuthenticationResults/Header.pm ↑ Summary lib/Mail/AuthenticationResults/FoldableHeader.pm »