lib/Mail/AuthenticationResults/Token/Comment.pm

filter: Statementstmt 100% 39 / 39 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 59 / 59 CC 7 SCAR 15.0
CC
7
Cov
100%
parse
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« blib/lib/Mail/AuthenticationResults/Header/SubEntry.pm ↑ Summary lib/Mail/AuthenticationResults/Header.pm »
1 package Mail::AuthenticationResults::Token::Comment;
2 # ABSTRACT: Class for modelling AuthenticationResults Header parts detected as comments
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 406 ▶sub is {
Subroutine is: called CC=1 SCAR=0.0
Pod documented
14 406 my ( $self ) = @_;
15 406 return 'comment';
16 }
17  
18 77 ▶sub parse {
Subroutine parse: called CC=7 SCAR=19.5
Pod documented
19 77 my ($self) = @_;
20  
21 77 my $header = $self->{ 'header' };
22 77 my $value = q{};
23 77 my $depth = 0;
24  
25 77 my $first = substr( $header,0,1 );
26 77 ▶ if ( $first ne '(' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first ne "(") 1 76 77
27 1 croak 'Not a comment';
28 }
29  
30 76 ▶ while ( length $header > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $header > 0) 1720 1 1721
31 1720 my $first = substr( $header,0,1 );
32 1720 $header = substr( $header,1 );
33 1720 $value .= $first;
34 1720 ▶ if ( $first eq '(' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($first eq '(') { } 77 1643 1720
elsif ($first eq ')') { } 76 1567 1643
35 77 $depth++;
36 }
37 elsif ( $first eq ')' ) {
38 76 $depth--;
39 76 ▶ last if $depth == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $depth == 0 75 1 76
40 }
41 }
42  
43 76 ▶ if ( $depth != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($depth != 0) 1 75 76
44 1 croak 'Mismatched parens in comment';
45 }
46  
47 75 $value =~ s/^\(//;
48 75 $value =~ s/\)$//;
49  
50 75 $self->{ 'value' } = $value;
51 75 $self->{ 'header' } = $header;
52  
53 75 return;
54 }
55  
56 31 1;
57  
58 __END__
« blib/lib/Mail/AuthenticationResults/Header/SubEntry.pm ↑ Summary lib/Mail/AuthenticationResults/Header.pm »