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 CC 3 SCAR 5.0
CC
3
Cov
74%
new
2.3
get_frames
2.0
to_bytes
2.0
CRAP 1.7
« WebSocket/X/UnfinishedStream.pm ↑ Summary WebSocket/Base/Typed.pm »
1 package Net::WebSocket::Message;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Call::Context ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 5 ▶ 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 5 5
10 0 die( (caller 0)[3] . ' needs at least one Net::WebSocket::Frame object!' );
11 }
12  
13 5 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 4 ▶ my ($self) = @_;
Subroutine get_payload: called CC=1 SCAR=0.0
Pod undocumented
26  
27 4 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 5 ▶ my $type = $_[0]->get_type();
Subroutine create_from_frames: called CC=2 SCAR=6.9
Pod undocumented
41  
42 5 my $class = __PACKAGE__ . "::$type";
43 5 ▶ if (!$class->can('new')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->can("new")) 2 3 5
44 2 Module::Load::load($class);
45 }
46  
47 5 return $class->new(@_);
48 }
49  
50 3 1;
« WebSocket/X/UnfinishedStream.pm ↑ Summary WebSocket/Base/Typed.pm »