Sietima/Role/StripHeaders.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 35 / 35 CC 5 SCAR 8.2
CC
5
Cov
100%
_strip_headers_from
4.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.3
« Sietima/Role/SubscriberOnly/Moderate.pm ↑ Summary Sietima/Role/Debounce.pm »
1 package Sietima::Role::StripHeaders;
2 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Sietima::Policy;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Types::Standard qw(ArrayRef RegexpRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '1.1.5'; # VERSION
8 # ABSTRACT: removes headers from incoming messages
9  
10  
11 has strip_headers => (
12 isa => ArrayRef[RegexpRef],
13 is => 'ro',
14 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
15 1 );
16  
17 2 ▶sub _strip_headers_from($self,$message) {
Subroutine _strip_headers_from: called CC=4 SCAR=13.9
18 2 my $mail = $message->mail;
19  
20 2 my $h = $mail->header_obj;
21 2 for my $name ($h->header_names) {
22 17 for my $rx ($self->strip_headers->@*) {
23 18 ▶ if ($name =~ $rx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /$rx/u) 2 16 18
24 2 $h->header_raw_set($name => ());
25 }
26 }
27 }
28 }
29  
30  
31 2 ▶around munge_mail => sub ($orig,$self,$mail) {
Subroutine __ANON__: called CC=2 SCAR=6.9
32 2 my @messages = $self->$orig($mail);
33 2 $self->_strip_headers_from($_) for @messages;
34 2 return @messages;
35 1 };
36  
37 1 1;
38  
39 __END__
« Sietima/Role/SubscriberOnly/Moderate.pm ↑ Summary Sietima/Role/Debounce.pm »