Box/Tie/HASH.pm

filter: Statementstmt 32.5% 14 / 43 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 33.3% 4 / 12 Podpod n/a totaltotal 24.0% 18 / 75 CC 9 SCAR 19.6
CC
9
Cov
24%
TIEHASH
12.0
STORE
12.0
NEXTKEY
12.0
CRAP 7.1
« Box/File/Message.pm ↑ Summary Box/Locker/Flock.pm »
1 # Copyrights 2001-2020 by [Mark Overmeer].
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.02.
5 # This code is part of distribution Mail-Box. 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::Box::Tie::HASH;
10 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '3.009';
12  
13  
14 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 sub TIEHASH(@)
21 0 ▶{ my ($class, $folder) = @_;
Subroutine TIEHASH: not called CC=3 SCAR=24.8
22 0 ▶ croak "No folder specified to tie to."
Branch: 1 branch
BranchTrueFalseTotal
unless ref $folder and $folder->isa("Mail::Box") 0 0 0
Condition0%0/3
ref $folder and $folder->isa("Mail::Box")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $folder and $folder->isa("Mail::Box")
ref $folder $folder->isa("Mail::Box")
Truth table0%0/3
A and B
A= ref $folderB= $folder->isa("Mail::Box")
ABresult
0X0
100
111
23 unless ref $folder && $folder->isa('Mail::Box');
24  
25 0 bless { MBT_folder => $folder, MBT_type => 'HASH' }, $class;
26 }
27  
28 #-------------------------------------------
29  
30 0 ▶sub FETCH($) { shift->{MBT_folder}->messageId(shift) }
Subroutine FETCH: not called CC=1 SCAR=6.9
31  
32  
33 sub STORE($$)
34 0 ▶{ my ($self, $key, $basicmsg) = @_;
Subroutine STORE: not called CC=3 SCAR=24.8
35  
36 0 ▶ carp "Use undef as key, because the message-id of the message is used."
Branch: 1 branch
BranchTrueFalseTotal
if defined $key and $key ne "undef" 0 0 0
Condition0%0/3
defined $key and $key ne "undef"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $key and $key ne "undef"
defined $key $key ne "undef"
Truth table0%0/3
A and B
A= defined $keyB= $key ne "undef"
ABresult
0X0
100
111
37 if defined $key && $key ne 'undef';
38  
39 0 $self->{MBT_folder}->addMessages($basicmsg);
40 }
41  
42  
43 sub FIRSTKEY()
44 0 ▶{ my $self = shift;
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
45 0 my $folder = $self->{MBT_folder};
46  
47 0 $self->{MBT_each_index} = 0;
48 0 $self->NEXTKEY();
49 }
50  
51 #-------------------------------------------
52  
53  
54 sub NEXTKEY($)
55 0 ▶{ my $self = shift;
Subroutine NEXTKEY: not called CC=3 SCAR=24.8
56 0 my $folder = $self->{MBT_folder};
57 0 my $nrmsgs = $folder->messages;
58  
59 0 my $msg;
60 0 while(1)
61 0 { my $index = $self->{MBT_each_index}++;
62 0 ▶ return undef if $index >= $nrmsgs;
Branch: 1 branch
BranchTrueFalseTotal
if $index >= $nrmsgs 0 0 0
63  
64 0 $msg = $folder->message($index);
65 0 ▶ last unless $msg->isDeleted;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg->isDeleted 0 0 0
66 }
67  
68 0 $msg->messageId;
69 }
70  
71  
72 sub EXISTS($)
73 0 ▶{ my $folder = shift->{MBT_folder};
Subroutine EXISTS: not called CC=2 SCAR=17.9
74 0 my $msgid = shift;
75 0 my $msg = $folder->messageId($msgid);
76 0 ▶ defined $msg && ! $msg->isDeleted;
Branch: 1 branch
BranchTrueFalseTotal
defined $msg and not $msg->isDeleted 0 0 0
77 }
78  
79  
80 sub DELETE($)
81 0 ▶{ my ($self, $msgid) = @_;
Subroutine DELETE: not called CC=1 SCAR=6.9
82 0 $self->{MBT_folder}->messageId($msgid)->delete;
83 }
84  
85 #-------------------------------------------
86  
87  
88 sub CLEAR()
89 0 ▶{ my $folder = shift->{MBT_folder};
Subroutine CLEAR: not called CC=2 SCAR=17.9
90 0 $_->delete foreach $folder->messages;
91 }
92  
93 #-------------------------------------------
94  
95 2 1;
« Box/File/Message.pm ↑ Summary Box/Locker/Flock.pm »