Header/Fields.pm

filter: Statementstmt 97.4% 233 / 239 Branchbran 80.1% 85 / 106 Conditioncond 50.0% 16 / 32 MC/DCmcdc 14.2% 3 / 21 Subroutinesub 97.7% 43 / 44 Podpod 0.0% 0 / 15 totaltotal 83.1% 380 / 457 CC 67 SCAR 13.2
CC
67
Cov
89%
new
8.0
cmp
6.6
cmp
6.6
CRAP 3.7
« v.pm ↑ Summary
1 package Data::Header::Fields;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use IO::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use String::Escape ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use List::MoreUtils 'uniq', 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 use overload
12 5 ▶ '""' => \&as_string,
Subroutine BEGIN: called CC=1 SCAR=0.0
13 'cmp' => \&cmp,
14 5 ;
15  
16 5 our $VERSION = '0.05';
17  
18 24 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
19 24 my $class = shift;
20 return bless {
21 tight_folding => 0,
22 66 ▶ key_cmp => sub { $_[0] cmp $_[1] },
Subroutine __ANON__: called CC=1 SCAR=0.0
23 @_
24 24 }, $class;
25 }
26  
27 194 ▶sub _lines {
Subroutine _lines: called CC=3 SCAR=11.0
28 194 my $self = shift;
29
30 $self->{_lines} = shift
31 194 ▶ if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 23 171 194
32
33 $self->{_lines} = []
34 194 ▶ if (not $self->{_lines});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_lines"} 8 186 194
35
36 194 return $self->{_lines};
37 }
38  
39 62 ▶sub key_cmp {
Subroutine key_cmp: called CC=2 SCAR=7.1
Pod undocumented
40 62 my $self = shift;
41 62 ▶ $self->{'key_cmp'} = shift
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 62 62
42 if @_;
43
44 62 return $self->{'key_cmp'};
45 }
46  
47 155 ▶sub tight_folding {
Subroutine tight_folding: called CC=3 SCAR=11.0
Pod undocumented
48 155 my $self = shift;
49
50 $self->{tight_folding} = shift
51 155 ▶ if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 155 155
52
53 155 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 65 90 155
54 if not ref $self;
55
56 90 return $self->{tight_folding};
57 }
58  
59 17 ▶sub decode {
Subroutine decode: called CC=4 SCAR=13.9
Pod undocumented
60 17 my $self = shift;
61 17 my $any = shift;
62
63 17 my @lines = $self->_read_lines($any);
64  
65 17 ▶ my $line_ending = (
Branch: 1 branch
BranchTrueFalseTotal
($lines[0] || '') =~ /\r\n \Z/msx ? : 4 13 17
Condition50%1/2
$lines[0] || ''
l!l
170
MC/DC0%0/1
$lines[0] || ''
$lines[0]
Truth table50%1/2
A
A= $lines[0]
Aresult
11
00
66 ($lines[0] || '') =~ m/\r\n \Z/xms
67 ? "\r\n"
68 : "\n"
69 );
70 17 $self->line_ending($line_ending);
71
72 @lines = (
73 map {
74 17 Data::Header::Fields::Line->new(
75 'line' => $_,
76 'parent' => $self,
77 );
78 } @lines
79 );
80
81 17 ▶ if (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) 16 1 17
82 16 $self->_lines(\@lines);
83 16 return $self;
84 }
85
86 1 return \@lines;
87 }
88  
89 11 ▶sub _read_lines {
Subroutine _read_lines: called CC=4 SCAR=13.9
90 11 my $self = shift;
91 11 my $any = shift;
92
93 11 my $fh = IO::Any->read($any);
94
95 # put folded lines to an array http://tools.ietf.org/html/rfc2822#section-2.2.3
96 11 my @lines;
97 11 ▶ while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 23 11 34
98 # folded line
99 23 ▶ if (($line =~ m/^\s/xms)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s/msx) 6 17 23
100 # ignore if the first line starts with white space
101 6 ▶ next if not @lines;
Branch: 1 branch
BranchTrueFalseTotal
unless @lines 0 6 6
102
103 6 $lines[-1] .= $line;
104 6 next;
105 }
106 17 push @lines, $line;
107 }
108
109 11 close $fh;
110  
111 11 return @lines;
112 }
113  
114 5 *as_string = *encode;
115 35 ▶sub encode {
Subroutine encode: called CC=5 SCAR=16.1
Pod undocumented
116 35 my $self = shift;
117 35 ▶ my $lines = shift || (ref $self ? $self->_lines : undef);
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 17 0 17
Condition66%2/3
shift() || (ref $self ? $self->_lines : undef)
l!l&&r!l&&!r
18170
MC/DC0%0/2
shift() || (ref $self ? $self->_lines : undef)
shift() (ref $self ? $self->_lines : undef)
Truth table66%2/3
A || B
A= shift()B= (ref $self ? $self->_lines : undef)
ABresult
1X1
011
000
118
119 # no additional arguments
120 35 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) 17 18 35
121 17 my $text = '';
122 17 $self->encode($lines, \$text);
123 17 return $text;
124 }
125
126 18 my $any = shift;
127
128 18 my $fh = IO::Any->write($any);
129 18 foreach my $line (@{$lines}) {
130 79 print $fh $line->as_string;
131 }
132
133 18 close $fh;
134
135 18 return $self;
136 }
137  
138 59 ▶sub get_fields {
Subroutine get_fields: called CC=2 SCAR=7.0
Pod undocumented
139 59 my $self = shift;
140 59 ▶ my $field_name = shift or croak 'field_name argument is mandatory';
Branch: 1 branch
BranchTrueFalseTotal
my $field_name = shift() or croak("field_name argument is mandatory") 59 0 59
141
142 59 my $key_cmp = $self->key_cmp;
143 return (
144 grep {
145 210 $key_cmp->($field_name, $_->key) == 0
146 59 } @{$self->_lines}
147 );
148 }
149  
150 53 ▶sub get_field {
Subroutine get_field: called CC=3 SCAR=11.2
Pod undocumented
151 53 my $self = shift;
152 53 ▶ my $field_name = shift or croak 'field_name argument is mandatory';
Branch: 1 branch
BranchTrueFalseTotal
my $field_name = shift() or croak("field_name argument is mandatory") 53 0 53
153 53 my @extra_args = @_;
154
155 53 my @fields = $self->get_fields($field_name, @extra_args);
156 53 ▶ croak 'more then one header field with name "'.$field_name.'"'
Branch: 1 branch
BranchTrueFalseTotal
if @fields > 1 0 53 53
157 if @fields > 1;
158
159 53 return $fields[0];
160 }
161  
162 53 ▶sub get_value {
Subroutine get_value: called CC=3 SCAR=11.0
Pod undocumented
163 53 my $self = shift;
164 53 ▶ my $key = shift or croak 'key argument is mandatory';
Branch: 1 branch
BranchTrueFalseTotal
my $key = shift() or croak("key argument is mandatory") 53 0 53
165 53 my @extra_args = @_;
166  
167 53 my $field = $self->get_field($key, @extra_args);
168 53 ▶ return undef if not defined $field;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $field 7 46 53
169 46 return $field->value;
170 }
171  
172 2 ▶sub update_values {
Subroutine update_values: called CC=3 SCAR=11.0
Pod undocumented
173 2 my $self = shift;
174 2 ▶ my $key = shift or croak 'key argument is mandatory';
Branch: 1 branch
BranchTrueFalseTotal
my $key = shift() or croak("key argument is mandatory") 2 0 2
175 2 my $value = shift;
176  
177 2 my $key_cmp = $self->key_cmp;
178 my @lines = (
179 map {
180 6 ▶ ($key_cmp->($_->key, $key) == 0 ? $_->value($value) : ());
Branch: 1 branch
BranchTrueFalseTotal
&$key_cmp($_->key, $key) == 0 ? : 2 4 6
181 6 $_;
182 2 } @{$self->_lines}
183 );
184
185 2 return $self;
186 }
187  
188 1 ▶sub rm_fields {
Subroutine rm_fields: called CC=2 SCAR=6.9
Pod undocumented
189 1 my $self = shift;
190 1 ▶ my (@field_names) = (@_) or croak 'field_names argument is mandatory';
Branch: 1 branch
BranchTrueFalseTotal
my(@field_names) = or croak("field_names argument is mandatory") 1 0 1
191  
192 1 my $key_cmp = $self->key_cmp;
193 my @lines = (
194 grep {
195 5 my $key = $_->key;
196 5 ▶ all { $key_cmp->($key, $_) != 0 } @field_names;
Subroutine __ANON__: called CC=1 SCAR=0.0
197 1 } @{$self->_lines}
198 );
199
200 1 $self->_lines(\@lines);
201
202 1 return $self;
203 }
204  
205 6 ▶sub set_value {
Subroutine set_value: called CC=4 SCAR=14.1
Pod undocumented
206 6 my $self = shift;
207 6 ▶ my $key = shift or croak 'key argument is mandatory';
Branch: 1 branch
BranchTrueFalseTotal
my $key = shift() or croak("key argument is mandatory") 6 0 6
208 6 my $value = shift;
209  
210 6 my @fields = $self->get_fields($key);
211 6 ▶ if (@fields == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@fields == 1) { } 2 4 6
elsif (@fields == 0) { } 4 0 4
212 2 $self->update_values($key, $value);
213 }
214 elsif (@fields == 0) {
215 4 push @{$self->_lines}, Data::Header::Fields::Line->new(
216 'key' => $key,
217 'value' => $value,
218 'parent' => $self,
219 );
220 }
221 else {
222 0 croak 'more then one header field with name "'.$key.'"';
223 }
224
225
226 6 return $self;
227 }
228  
229 2 ▶sub cmp {
Subroutine cmp: called CC=5 SCAR=18.9
Pod undocumented
230 2 my $a = shift;
231 2 my $b = shift;
232
233 2 ▶ $a = $a->encode if ref $a and $a->can('encode');
Branch: 1 branch
BranchTrueFalseTotal
if ref $a and $a->can("encode") 2 0 2
Condition33%1/3
ref $a and $a->can("encode")
!ll&&!rl&&r
002
MC/DC0%0/2
ref $a and $a->can("encode")
ref $a $a->can("encode")
Truth table33%1/3
A and B
A= ref $aB= $a->can("encode")
ABresult
0X0
100
111
234 2 ▶ $b = $b->encode if ref $b and $b->can('encode');
Branch: 1 branch
BranchTrueFalseTotal
if ref $b and $b->can("encode") 0 2 2
Condition33%1/3
ref $b and $b->can("encode")
!ll&&!rl&&r
200
MC/DC0%0/2
ref $b and $b->can("encode")
ref $b $b->can("encode")
Truth table33%1/3
A and B
A= ref $bB= $b->can("encode")
ABresult
0X0
100
111
235
236 2 return $a cmp $b;
237 }
238  
239 4 ▶sub keys {
Subroutine keys: called CC=3 SCAR=11.2
Pod undocumented
240 4 my $self = shift;
241 4 ▶ my $lines = shift || (ref $self ? $self->_lines : []);
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 3 0 3
Condition66%2/3
shift() || (ref $self ? $self->_lines : [])
l!l&&r!l&&!r
130
MC/DC0%0/2
shift() || (ref $self ? $self->_lines : [])
shift() (ref $self ? $self->_lines : [])
Truth table66%2/3
A || B
A= shift()B= (ref $self ? $self->_lines : [])
ABresult
1X1
011
000
242
243 return
244 uniq
245 map {
246 6 $_->key
247 4 } @{$lines}
248 ;
249 }
250  
251 54 ▶sub line_ending {
Subroutine line_ending: called CC=4 SCAR=13.9
Pod undocumented
252 54 my $self = shift;
253
254 54 ▶ return "\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 13 41 54
255 if not ref $self;
256
257 41 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 16 25 41
258 16 $self->{line_ending} = shift;
259 }
260 $self->{line_ending} = "\n"
261 41 ▶ if (not $self->{line_ending});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"line_ending"} 1 40 41
262
263 41 return $self->{line_ending};
264 }
265  
266 0 ▶sub push_line {
Subroutine push_line: not called CC=1 SCAR=6.9
Pod undocumented
267 0 my $self = shift;
268 0 my $line = shift;
269  
270 0 my $lines = $self->_lines;
271 0 push(@$lines, $line);
272  
273 0 return $self;
274 }
275  
276 5 1;
277  
278 package Data::Header::Fields::Value;
279  
280 5 ▶use Scalar::Util 'weaken', 'isweak';
Subroutine BEGIN: called CC=1 SCAR=0.0
281  
282 use overload
283 5 ▶ '""' => \&as_string,
Subroutine BEGIN: called CC=1 SCAR=0.0
284 'cmp' => \&cmp,
285 5 ;
286  
287 202 ▶sub new {
Subroutine new: called CC=5 SCAR=16.2
288 202 my $class = shift;
289 202 my $value = shift;
290
291 202 ▶ if (@_ == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0) { } 68 134 202
292 68 ▶ if (not ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value) 68 0 68
293 68 $value = { 'value' => $value };
294 }
295 }
296 else {
297 134 $value = { $value, @_ };
298 }
299
300 202 my $self = bless { 'parent' => $class->_default_parent, %{$value} }, $class;
301
302 weaken($self->{'parent'})
303 202 ▶ if (ref($self->{'parent'}) && !isweak($self->{'parent'}));
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"parent"} and not builtin::is_weak($self->{"parent"}) 129 73 202
Condition66%2/3
ref $self->{"parent"} and not builtin::is_weak($self->{"parent"})
!ll&&!rl&&r
730129
MC/DC50%1/2
ref $self->{"parent"} and not builtin::is_weak($self->{"parent"})
ref $self->{"parent"} not builtin::is_weak($self->{"parent"})
Truth table66%2/3
A and not(B)
A= ref $self->{"parent"}B= not builtin::is_weak($self->{"parent"})
ABresult
0X0
100
111
304
305 202 return $self;
306 }
307  
308 155 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
309 155 my $self = shift;
310  
311 # remove folding
312 155 my $line = $self->{value};
313 155 ▶ if ($self->parent->parent->tight_folding) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->parent->parent->tight_folding) { } 83 72 155
314 83 $line =~ s/\n\s//xmsg;
315 }
316 else {
317 72 $line =~ s/\n(\s)/$1/xmsg;
318 }
319 155 $line =~ s/\r?\n$//;
320 155 $line = String::Escape::unprintable($line);
321
322 155 return $line;
323 }
324  
325 25 ▶sub cmp {
Subroutine cmp: called CC=5 SCAR=17.0
326 25 my $a = shift;
327 25 my $b = shift;
328
329 25 ▶ $a = $a->as_string if ref $a and $a->can('as_string');
Branch: 1 branch
BranchTrueFalseTotal
if ref $a and $a->can("as_string") 25 0 25
Condition33%1/3
ref $a and $a->can("as_string")
!ll&&!rl&&r
0025
MC/DC0%0/2
ref $a and $a->can("as_string")
ref $a $a->can("as_string")
Truth table33%1/3
A and B
A= ref $aB= $a->can("as_string")
ABresult
0X0
100
111
330 25 ▶ $b = $b->as_string if ref $b and $b->can('as_string');
Branch: 1 branch
BranchTrueFalseTotal
if ref $b and $b->can("as_string") 2 23 25
Condition66%2/3
ref $b and $b->can("as_string")
!ll&&!rl&&r
2302
MC/DC50%1/2
ref $b and $b->can("as_string")
ref $b $b->can("as_string")
Truth table66%2/3
A and B
A= ref $bB= $b->can("as_string")
ABresult
0X0
100
111
331
332 25 return $a cmp $b;
333 }
334  
335 263 ▶sub _default_parent {
Subroutine _default_parent: called CC=1 SCAR=0.0
336 263 return 'Data::Header::Fields::Line';
337 }
338  
339 163 ▶sub parent {
Subroutine parent: called CC=3 SCAR=11.0
340 163 my $self = shift;
341 163 ▶ $self->{'parent'} = shift
Branch: 1 branch
BranchTrueFalseTotal
if @_ 3 160 163
342 if @_;
343
344 163 ▶ return (ref $self->{'parent'} ? $self->{'parent'} : $self->_default_parent);
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{'parent'} ? : 102 61 163
345 }
346  
347 7 ▶sub value {
Subroutine value: called CC=2 SCAR=6.9
348 7 my $self = shift;
349
350 7 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 5 2 7
351 5 $self->{'value'} = shift;
352 5 $self->parent->line_changed;
353 }
354
355 7 return $self->{'value'};
356 }
357 5 1;
358  
359 package Data::Header::Fields::Line;
360  
361 5 ▶use Scalar::Util 'blessed', 'weaken', 'isweak';
Subroutine BEGIN: called CC=1 SCAR=0.0
362  
363 use overload
364 5 ▶ '""' => \&as_string,
Subroutine BEGIN: called CC=1 SCAR=0.0
365 'cmp' => \&cmp,
366 5 ;
367  
368 193 ▶sub new {
Subroutine new: called CC=8 SCAR=20.8
369 193 my $class = shift;
370 193 my $line = shift;
371 193 my @args = @_;
372
373 193 ▶ if (@args > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args > 0) 190 3 193
374 190 $line = { $line, @args };
375 }
376
377 193 ▶ if (not ref $line) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $line) 2 191 193
378 2 $line = { 'line' => $line };
379 }
380
381 193 $line = { 'parent' => $class->_default_parent, %{$line} };
382
383 193 ▶ if (exists $line->{'line'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $line->{"line"}) 183 10 193
384 # reblessing the line object
385 183 ▶ if (blessed $line->{'line'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($line->{'line'})) { } 72 111 183
386 72 my $self = delete $line->{'line'};
387 72 foreach my $key (keys %{$line}) {
388 72 $self->{$key} = $line->{$key};
389 }
390 72 return bless $self, $class;
391 }
392 else {
393 111 my $line_string = delete $line->{'line'};
394 111 $line->{'original_line'} = $line_string;
395 111 my ($key, $value) = split(/:/, $line_string, 2);
396 111 $line->{'key'} = $key;
397 111 $line->{'value'} = Data::Header::Fields::Value->new(
398 'value' => $value,
399 'parent' => $line,
400 );
401 }
402 }
403
404 weaken($line->{'parent'})
405 121 ▶ if (ref($line->{'parent'}) && !isweak($line->{'parent'}));
Branch: 1 branch
BranchTrueFalseTotal
if ref $line->{"parent"} and not builtin::is_weak($line->{"parent"}) 115 6 121
Condition66%2/3
ref $line->{"parent"} and not builtin::is_weak($line->{"parent"})
!ll&&!rl&&r
60115
MC/DC50%1/2
ref $line->{"parent"} and not builtin::is_weak($line->{"parent"})
ref $line->{"parent"} not builtin::is_weak($line->{"parent"})
Truth table66%2/3
A and not(B)
A= ref $line->{"parent"}B= not builtin::is_weak($line->{"parent"})
ABresult
0X0
100
111
406
407 121 return bless $line, $class;
408 }
409  
410 789 ▶sub key {
Subroutine key: called CC=2 SCAR=6.9
411 789 my $self = shift;
412 789 ▶ $self->{'key'} = shift
Branch: 1 branch
BranchTrueFalseTotal
if @_ 72 717 789
413 if @_;
414
415 789 return $self->{'key'};
416 }
417 200 ▶sub value {
Subroutine value: called CC=2 SCAR=6.9
418 200 my $self = shift;
419 200 ▶ $self->line_changed->{'value'} = shift
Branch: 1 branch
BranchTrueFalseTotal
if @_ 3 197 200
420 if @_;
421
422 200 return $self->{'value'};
423 }
424  
425 16 ▶sub line_changed {
Subroutine line_changed: called CC=2 SCAR=6.9
426 16 my $self = shift;
427 16 ▶ delete $self->{'original_line'}
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 14 2 16
428 if ref $self;
429 16 return $self;
430 }
431  
432 104 ▶sub as_string {
Subroutine as_string: called CC=4 SCAR=13.9
433 104 my $self = shift;
434
435 104 ▶ if (exists $self->{'original_line'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"original_line"}) 94 10 104
436 94 my $original_line = $self->{'original_line'};
437
438 # make sure the line has line_ending, even the original one could be created without using ->new()
439 94 ▶ $original_line .= $self->parent->line_ending
Branch: 1 branch
BranchTrueFalseTotal
unless $original_line =~ / \n \Z /msx 1 93 94
440 if $original_line !~ m/ \n \Z /xms;
441
442 94 return $original_line;
443 }
444  
445 10 my ($key, $value) = ($self->key, $self->value);
446 10 $value = String::Escape::printable($value);
447  
448 10 my $line = join(':', $key, $value);
449
450 10 ▶ $line .= $self->parent->line_ending
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /\n$/msx 10 0 10
451 if $line !~ m/\n$/xms;
452
453 10 return $line;
454 }
455  
456 3 ▶sub cmp {
Subroutine cmp: called CC=5 SCAR=18.9
457 3 my $a = shift;
458 3 my $b = shift;
459
460 3 ▶ $a = $a->as_string if ref $a and $a->can('as_string');
Branch: 1 branch
BranchTrueFalseTotal
if ref $a and $a->can("as_string") 3 0 3
Condition33%1/3
ref $a and $a->can("as_string")
!ll&&!rl&&r
003
MC/DC0%0/2
ref $a and $a->can("as_string")
ref $a $a->can("as_string")
Truth table33%1/3
A and B
A= ref $aB= $a->can("as_string")
ABresult
0X0
100
111
461 3 ▶ $b = $b->as_string if ref $b and $b->can('as_string');
Branch: 1 branch
BranchTrueFalseTotal
if ref $b and $b->can("as_string") 0 3 3
Condition33%1/3
ref $b and $b->can("as_string")
!ll&&!rl&&r
300
MC/DC0%0/2
ref $b and $b->can("as_string")
ref $b $b->can("as_string")
Truth table33%1/3
A and B
A= ref $bB= $b->can("as_string")
ABresult
0X0
100
111
462
463 3 return $a cmp $b;
464 }
465  
466 262 ▶sub _default_parent {
Subroutine _default_parent: called CC=1 SCAR=0.0
467 262 return 'Data::Header::Fields';
468 }
469  
470 223 ▶sub parent {
Subroutine parent: called CC=3 SCAR=11.1
471 223 my $self = shift;
472 223 ▶ $self->{'parent'} = shift
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 223 223
473 if @_;
474
475 223 ▶ return (ref $self ? $self->{'parent'} : $self->_default_parent);
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 154 69 223
476 }
477  
478  
479 5 1;
480  
481  
482 __END__
« v.pm ↑ Summary