lib/Mail/AuthenticationResults/Token/String.pm

filter: Statementstmt 100% 44 / 44 Branchbran 92.8% 26 / 28 Conditioncond 66.6% 20 / 30 MC/DCmcdc 46.6% 7 / 15 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 84.0% 105 / 125 CC 25 SCAR 31.1
CC
25
Cov
88%
parse
26.8
BEGIN
1.0
BEGIN
1.0
CRAP 22.5
« blib/lib/Mail/AuthenticationResults/Header/Group.pm ↑ Summary blib/lib/Mail/AuthenticationResults/Token/Comment.pm »
1 package Mail::AuthenticationResults::Token::String;
2 # ABSTRACT: Class for modelling AuthenticationResults Header parts detected as strings
3  
4 31 require 5.008;
5 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 31 our $VERSION = '2.20260216'; # VERSION
8 31 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 31 ▶use base 'Mail::AuthenticationResults::Token';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 4486 ▶sub is {
Subroutine is: called CC=1 SCAR=0.0
Pod documented
14 4486 my ( $self ) = @_;
15 4486 return 'string';
16 }
17  
18 657 ▶sub parse {
Subroutine parse: called CC=25 SCAR=32.9
Pod documented
19 657 my ($self) = @_;
20  
21 657 my $header = $self->{ 'header' };
22 657 my $value = q{};
23  
24 657 ▶ croak 'Not a string' if $header =~ /^"/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^"/ 1 656 657
25 656 ▶ croak 'Not a string' if $header =~ /^\(/;
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /^\(/ 1 655 656
26  
27 # Parse differently if we are post assignment (we are a value) or not (we are likely a key or key part)
28 655 my $is_value = 0;
29 655 my $is_first = 0;
30 655 ▶ if ( exists ( $self->{ 'args' }->{ 'last_non_comment_type' } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'args'}{'last_non_comment_type'}) { } 594 61 655
31 594 ▶ if ( $self->{ 'args' }->{ 'last_non_comment_type' }->is() eq 'assignment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"args"}{"last_non_comment_type"}->is eq "assignment") 326 268 594
32 326 ▶ if ( $self->{ 'args' }->{ 'last_non_comment_type' }->value() eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"args"}{"last_non_comment_type"}->value eq "=") 243 83 326
33 243 $is_value = 1;
34 }
35 }
36 }
37 else {
38 61 $is_first = 1;
39 }
40  
41 655 ▶ while ( length $header > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $header > 0) 5364 36 5400
42 5364 my $first = substr( $header,0,1 );
43 5364 ▶ last if $first =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $first =~ /\s/ 205 5159 5364
44 5159 ▶ last if $first eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $first eq ";" 98 5061 5159
45 5061 ▶ last if $first eq '"' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "\"" and not $is_value and not $is_first 0 5061 5061
Condition33%2/6
$first eq "\"" and not $is_value and not $is_first
!ll&&!rl&&r
506100
$first eq "\"" and not $is_value
!ll&&!rl&&r
506100
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 5061 ▶ last if $first eq '(' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "(" and not $is_value and not $is_first 0 5061 5061
Condition33%2/6
$first eq "(" and not $is_value and not $is_first
!ll&&!rl&&r
506100
$first eq "(" and not $is_value
!ll&&!rl&&r
506100
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 5061 ▶ last if $first eq '=' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "=" and not $is_value and not $is_first 239 4822 5061
Condition83%5/6
$first eq "=" and not $is_value and not $is_first
!ll&&!rl&&r
48220239
$first eq "=" and not $is_value
!ll&&!rl&&r
48211239
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 4822 ▶ last if $first eq '/' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "/" and not $is_value and not $is_first 1 4821 4822
Condition83%5/6
$first eq "/" and not $is_value and not $is_first
!ll&&!rl&&r
482101
$first eq "/" and not $is_value
!ll&&!rl&&r
481471
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
49 4821 ▶ last if $first eq '.' && ! $is_value && ! $is_first;
Branch: 1 branch
BranchTrueFalseTotal
if $first eq "." and not $is_value and not $is_first 76 4745 4821
Condition100%6/6
$first eq "." and not $is_value and not $is_first
!ll&&!rl&&r
463710876
$first eq "." and not $is_value
!ll&&!rl&&r
4522115184
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 4745 $value .= $first;
52 4745 $header = substr( $header,1 );
53 }
54  
55 655 ▶ croak 'Not a string' if $value eq q{};
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 6 649 655
56  
57 649 $self->{ 'value' } = $value;
58 649 $self->{ 'header' } = $header;
59  
60 649 return;
61 }
62  
63 31 1;
64  
65 __END__
« blib/lib/Mail/AuthenticationResults/Header/Group.pm ↑ Summary blib/lib/Mail/AuthenticationResults/Token/Comment.pm »