Client/ModmailConversation.pm

filter: Statementstmt 47.0% 16 / 34 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod 33.3% 1 / 3 totaltotal 36.6% 22 / 60 CC 8 SCAR 27.6
CC
8
Cov
34%
set_messages
30.0
new
20.0
archive
2.0
CRAP 15.8
« Client/Thing.pm ↑ Summary Client/Comment.pm »
1 package Reddit::Client::ModmailConversation;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 require Reddit::Client::Thing;
7 5 ▶use base qw/Reddit::Client::Thing/; # base doesn't require. use parent does
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # what will happpen if we use Thing as a parent but don't use fields here? Proly
10 # those fields cause errs. # Just use them, no sense fucking with it now
11 # id
12 5 ▶use fields qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
13 authors
14 isAuto
15 isHighlighted
16 isInternal
17 isRepliable
18 lastModUpdate
19 lastUnread
20 lastUpdated
21 lastUserUpdate
22 numMessages
23 objIds
24 owner
25 participant
26 state
27 subject
28  
29 messages
30 modActions
31 5 /;
32  
33 # no type, apparently. None listed in docs. Message is t4, but no indication
34 # these are Messages
35 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
36 0 my ($class, $reddit, $conversation, $messages, $modActions) = @_;
37 0 my $data = $conversation;
38 0 ▶ if (ref $data eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq 'HASH') { } 0 0 0
39 # if we put messages here, we have to use fuckery to make it come after
40 # isObj, because that must exist first. might as well just call our
41 # thing after.
42 #$data->{messages} = $messages if $messages;
43 0 ▶ $data->{modActions} = $modActions if $modActions;
Branch: 1 branch
BranchTrueFalseTotal
if $modActions 0 0 0
44 } else {
45 0 die "Expected a hash reference for arg 2\n";
46 }
47 0 my $this = $class->SUPER::new($reddit, $data);
48 0 ▶ $this->set_messages($messages) if $messages;
Branch: 1 branch
BranchTrueFalseTotal
if $messages 0 0 0
49  
50 0 return $this;
51 }
52  
53 # Expects hash reference containing hash references of arbitrary keys
54 # (keys are message IDs)
55 0 ▶sub set_messages {
Subroutine set_messages: not called CC=5 SCAR=34.0
Pod undocumented
56 0 my ($this, $msgdat) = @_;
57  
58 # this should create an array of ModmailMessages out of $messages using the
59 # order in objIds. objIds must be set first
60  
61 0 my $messages = [];
62  
63 0 ▶ if (ref $this->{objIds} eq 'ARRAY' and ref $msgdat eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $this->{"objIds"} eq "ARRAY" and ref $msgdat eq "HASH") 0 0 0
Condition0%0/3
ref $this->{"objIds"} eq "ARRAY" and ref $msgdat eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $this->{"objIds"} eq "ARRAY" and ref $msgdat eq "HASH"
ref $this->{"objIds"} eq "ARRAY" ref $msgdat eq "HASH"
Truth table0%0/3
A and B
A= ref $this->{"objIds"} eq "ARRAY"B= ref $msgdat eq "HASH"
ABresult
0X0
100
111
64 0 for my $o ( @{$this->{objIds}}) {
65 0 ▶ if ($o->{key} eq 'messages') {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"key"} eq "messages") 0 0 0
66 0 push @$messages, new Reddit::Client::ModmailMessage( $this->{session}, $msgdat->{$o->{id}} );
67 }
68 }
69 0 $this->{messages} = $messages;
70 }
71  
72 }
73  
74 0 ▶sub archive {
Subroutine archive: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my $this = shift;
76 0 return $this->{session}->modmail_action('archive', $this->{id});
77 }
78  
« Client/Thing.pm ↑ Summary Client/Comment.pm »