Box/Tie/HASH.pm

filter: Statementstmt 82.9% 34 / 41 Branchbran 62.5% 5 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 9 / 12 Podpod n/a totaltotal 75.7% 50 / 66 CC 7 SCAR 10.5
CC
7
Cov
79%
EXISTS
6.0
CLEAR
6.0
STORE
3.1
CRAP 2.9
« Message/Head/Delayed.pm ↑ Summary Box/Tie/ARRAY.pm »
1 # This code is part of Perl distribution Mail-Box version 4.02.
2 # The POD got stripped from this file by OODoc version 3.06.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2026 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Box::Tie::HASH;{
13 2 our $VERSION = '4.02';
14 }
15  
16 2 ▶use parent 'Mail::Box::Tie';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 ▶use Log::Report 'mail-box', import => [ qw/__x warning/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #--------------------
24  
25 sub TIEHASH(@)
26 1 ▶{ my ($class, $folder) = @_;
Subroutine TIEHASH: called CC=1 SCAR=0.0
27 1 $class->new($folder, 'HASH');
28 }
29  
30 #--------------------
31  
32 #--------------------
33  
34 139 ▶sub FETCH($) { $_[0]->folder->messageId($_[1]) }
Subroutine FETCH: called CC=1 SCAR=0.0
35  
36  
37 sub STORE($$)
38 2 ▶{ my ($self, $key, $basicmsg) = @_;
Subroutine STORE: called CC=3 SCAR=11.4
39  
40 2 ▶ ! defined $key || $key eq 'undef'
Branch: 1 branch
BranchTrueFalseTotal
not defined $key or $key eq "undef" or &warning(&__x("use undef as key, because the message-id of the message is used.")) 2 0 2
Condition66%2/3
not defined $key or $key eq "undef"
l!l&&r!l&&!r
110
MC/DC0%0/2
not defined $key or $key eq "undef"
not defined $key $key eq "undef"
Truth table66%2/3
not(A) or B
A= not defined $keyB= $key eq "undef"
ABresult
1X1
011
000
41 or warning __x"use undef as key, because the message-id of the message is used.";
42  
43 2 $self->folder->addMessages($basicmsg);
44 }
45  
46  
47 sub FIRSTKEY()
48 6 ▶{ my $self = shift;
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
49 6 $self->{MBT_each_index} = 0;
50 6 $self->NEXTKEY();
51 }
52  
53  
54 sub NEXTKEY($)
55 274 ▶{ my $self = shift;
Subroutine NEXTKEY: called CC=3 SCAR=11.0
56 274 my $folder = $self->{MBT_folder};
57 274 my $nrmsgs = $folder->messages;
58  
59 274 my $msg;
60 274 while(1)
61 277 { my $index = $self->{MBT_each_index}++;
62 277 ▶ $index < $nrmsgs or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$index < $nrmsgs or return undef 271 6 277
63 271 $msg = $folder->message($index);
64 271 ▶ $msg->isDeleted or last;
Branch: 1 branch
BranchTrueFalseTotal
$msg->isDeleted or last 3 268 271
65 }
66  
67 268 $msg->messageId;
68 }
69  
70  
71 sub EXISTS($)
72 0 ▶{ my ($self, $msgid) = @_;
Subroutine EXISTS: not called CC=2 SCAR=17.9
73 0 my $msg = $self->folder->messageId($msgid);
74 0 ▶ defined $msg && ! $msg->isDeleted;
Branch: 1 branch
BranchTrueFalseTotal
defined $msg and not $msg->isDeleted 0 0 0
75 }
76  
77  
78 sub DELETE($)
79 0 ▶{ my ($self, $msgid) = @_;
Subroutine DELETE: not called CC=1 SCAR=6.9
80 0 $self->folder->messageId($msgid)->delete;
81 }
82  
83  
84 sub CLEAR()
85 0 ▶{ my $self = shift;
Subroutine CLEAR: not called CC=2 SCAR=17.9
86 0 $_->delete for $self->folder->messages;
87 }
88  
89 2 1;
« Message/Head/Delayed.pm ↑ Summary Box/Tie/ARRAY.pm »