Message/Field/URIs.pm

filter: Statementstmt 93.6% 44 / 47 Branchbran 61.1% 11 / 18 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 90.9% 10 / 11 Podpod 83.3% 5 / 6 totaltotal 83.9% 73 / 87 CC 13 SCAR 16.1
CC
13
Cov
84%
init
10.0
addURI
3.0
produceBody
2.0
CRAP 5.0
« Message/Field/Unstructured.pm ↑ Summary Reporter.pm »
1 # Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution Mail-Message. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Message::Field::URIs;
10 23 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 23 $VERSION = '3.012';
12  
13 23 ▶use base 'Mail::Message::Field::Structured';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 23 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21  
22 sub init($)
23 3 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=9 SCAR=23.0
Pod undocumented
24  
25 3 my ($body, @body);
26 3 ▶ if($body = delete $args->{body})
Branch: 1 branch
BranchTrueFalseTotal
if ($body = delete $args->{"body"}) 3 0 3
27 3 ▶ { @body = ref $body eq 'ARRAY' ? @$body : ($body);
Branch: 1 branch
BranchTrueFalseTotal
ref $body eq 'ARRAY' ? : 0 3 3
28 3 ▶ return () unless @body;
Branch: 1 branch
BranchTrueFalseTotal
unless @body 0 3 3
29 }
30  
31 3 $self->{MMFU_uris} = [];
32  
33 3 ▶ if(@body > 1 || ref $body[0])
Branch: 2 branches
BranchTrueFalseTotal
if (@body > 1 or ref $body[0]) { } 2 1 3
elsif (defined $body) { } 1 0 1
Condition66%2/3
@body > 1 or ref $body[0]
l!l&&r!l&&!r
021
MC/DC50%1/2
@body > 1 or ref $body[0]
@body > 1 ref $body[0]
Truth table66%2/3
A or B
A= @body > 1B= ref $body[0]
ABresult
1X1
011
000
34 2 { $self->addURI($_) foreach @body;
35 }
36 elsif(defined $body)
37 1 ▶ { $body = "<$body>\n" unless index($body, '<') >= 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($body, "<") != -1 0 1 1
38 1 $args->{body} = $body;
39 }
40  
41 3 $self->SUPER::init($args);
42 }
43  
44 sub parse($)
45 1 ▶{ my ($self, $string) = @_;
Subroutine parse: called CC=2 SCAR=6.9
Pod documented
46 1 my @raw = $string =~ m/\<([^>]+)\>/g; # simply ignore all but <>
47 1 $self->addURI($_) foreach @raw;
48 1 $self;
49 }
50  
51 sub produceBody()
52 3 ▶{ my @uris = sort map { $_->as_string } shift->URIs;
Subroutine produceBody: called CC=2 SCAR=7.0
Pod documented
53 3 local $" = '>, <';
54 3 ▶ @uris ? "<@uris>" : undef;
Branch: 1 branch
BranchTrueFalseTotal
@uris ? : 3 0 3
55 }
56  
57 #------------------------------------------
58  
59  
60 sub addURI(@)
61 5 ▶{ my $self = shift;
Subroutine addURI: called CC=3 SCAR=11.0
Pod documented
62 5 ▶ my $uri = ref $_[0] ? shift : URI->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 2 3 5
63 5 ▶ push @{$self->{MMFU_uris}}, $uri->canonical if defined $uri;
Branch: 1 branch
BranchTrueFalseTotal
if defined $uri 5 0 5
64 5 delete $self->{MMFF_body};
65 5 $uri;
66 }
67  
68  
69 6 ▶sub URIs() { @{shift->{MMFU_uris}} }
Subroutine URIs: called CC=1 SCAR=0.0
Pod documented
70  
71  
72 sub addAttribute($;@)
73 0 ▶{ my $self = shift;
Subroutine addAttribute: not called CC=1 SCAR=6.9
Pod documented
74 0 $self->log(ERROR => 'No attributes for URI fields.');
75 0 $self;
76 }
77  
78 #------------------------------------------
79  
80  
81 23 1;
« Message/Field/Unstructured.pm ↑ Summary Reporter.pm »