WebSocket/Message.pm

filter: Statementstmt 74.0% 20 / 27 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 5 totaltotal 65.9% 29 / 44 SCAR 11.5
CC
3
Cov
74%
new
2.3
get_frames
2.0
to_bytes
2.0
CRAP 3.2
« WebSocket/PingStore.pm ↑ Summary WebSocket/Base/DataFrame.pm »
1 package Net::WebSocket::Message;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Call::Context ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 10 ▶ if (!$_[1]->isa('Net::WebSocket::Frame')) {
Subroutine new: called CC=2 SCAR=8.1
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless ($_[1]->isa("Net::WebSocket::Frame")) 0 10 10
10 0 die( (caller 0)[3] . ' needs at least one Net::WebSocket::Frame object!' );
11 }
12  
13 10 return bless \@_, shift;
14 }
15  
16 sub get_frames {
17 0 ▶ my ($self) = @_;
Subroutine get_frames: not called CC=1 SCAR=6.9
Pod undocumented
18  
19 0 Call::Context::must_be_list();
20  
21 0 return @$self;
22 }
23  
24 sub get_payload {
25 12 ▶ my ($self) = @_;
Subroutine get_payload: called CC=1 SCAR=0.0
Pod undocumented
26  
27 12 return join( q<>, map { $_->get_payload() } @$self );
28 }
29  
30 sub to_bytes {
31 0 ▶ my ($self) = @_;
Subroutine to_bytes: not called CC=1 SCAR=6.9
Pod undocumented
32  
33 0 return join( q<>, map { $_->to_bytes() } @$self );
34 }
35  
36 #----------------------------------------------------------------------
37 # Static function that auto-loads the actual message class.
38  
39 sub create_from_frames {
40 10 ▶ my $type = $_[0]->get_type();
Subroutine create_from_frames: called CC=2 SCAR=6.9
Pod undocumented
41  
42 10 my $class = __PACKAGE__ . "::$type";
43 10 ▶ if (!$class->can('new')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->can("new")) 5 5 10
44 5 Module::Load::load($class);
45 }
46  
47 10 return $class->new(@_);
48 }
49  
50 4 1;
« WebSocket/PingStore.pm ↑ Summary WebSocket/Base/DataFrame.pm »