Message/Subscribe.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 100% 55 / 55 CC 3 SCAR 2.5
CC
3
Cov
100%
_parse_remaining
2.0
_remaining_bytes
2.0
BEGIN
1.0
CRAP 1.3
« Message/SubAck.pm ↑ Summary Message/Unsubscribe.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Net::MQTT::Message::Subscribe;
4 3 $Net::MQTT::Message::Subscribe::VERSION = '1.143250';
5 # ABSTRACT: Perl module to represent an MQTT Subscribe message
6  
7  
8 3 ▶use base 'Net::MQTT::Message';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Net::MQTT::Constants qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub message_type {
12 7 ▶ 8
Subroutine message_type: called CC=1 SCAR=0.0
Pod documented
13 }
14  
15 sub _default_qos {
16 2 ▶ MQTT_QOS_AT_LEAST_ONCE
Subroutine _default_qos: called CC=1 SCAR=0.0
17 }
18  
19  
20 4 ▶sub message_id { shift->{message_id} }
Subroutine message_id: called CC=1 SCAR=0.0
Pod documented
21  
22  
23 2 ▶sub topics { shift->{topics} }
Subroutine topics: called CC=1 SCAR=0.0
Pod documented
24  
25 sub _topics_string {
26 2 ▶ join ',', map { $_->[0].'/'.qos_string($_->[1]) } @{shift->{topics}}
Subroutine _topics_string: called CC=1 SCAR=0.0
27 }
28  
29 sub _remaining_string {
30 2 ▶ my ($self, $prefix) = @_;
Subroutine _remaining_string: called CC=1 SCAR=0.0
31 2 $self->message_id.' '.$self->_topics_string.' '.
32 $self->SUPER::_remaining_string($prefix)
33 }
34  
35 sub _parse_remaining {
36 1 ▶ my $self = shift;
Subroutine _parse_remaining: called CC=2 SCAR=6.9
37 1 my $offset = 0;
38 1 $self->{message_id} = decode_short($self->{remaining}, \$offset);
39 1 ▶ while ($offset < length $self->{remaining}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset < length $self->{"remaining"}) 1 1 2
40 1 push @{$self->{topics}}, [ decode_string($self->{remaining}, \$offset),
41 1 decode_byte($self->{remaining}, \$offset) ];
42 }
43 1 substr $self->{remaining}, 0, $offset, '';
44 }
45  
46 sub _remaining_bytes {
47 2 ▶ my $self = shift;
Subroutine _remaining_bytes: called CC=2 SCAR=6.9
48 2 my $o = encode_short($self->message_id);
49 2 foreach my $r (@{$self->topics}) {
50 2 my ($name, $qos) = @$r;
51 2 $o .= encode_string($name);
52 2 $o .= encode_byte($qos);
53 }
54 $o
55 2 }
56  
57 3 1;
58  
59 __END__
« Message/SubAck.pm ↑ Summary Message/Unsubscribe.pm »