AnyEvent/Connection.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 42.8% 3 / 7 Podpod 100% 3 / 3 totaltotal 30.8% 21 / 68 CC 7 SCAR 34.3
CC
7
Cov
29%
send
56.0
new
2.0
close
2.0
CRAP 30.8
↑ Summary AnyEvent.pm »
1 package Kelp::Module::WebSocket::AnyEvent::Connection;
2 2 $Kelp::Module::WebSocket::AnyEvent::Connection::VERSION = '1.05';
3 2 ▶use Kelp::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Scalar::Util qw(weaken blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 attr "-id";
8 2 attr "-manager";
9 2 attr "-connection";
10 0 ▶attr "data" => sub { {} };
Subroutine __ANON__: not called CC=1 SCAR=1.2
11  
12 sub new
13 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
14 0 my $class = shift;
15 0 my $self = $class->SUPER::new(@_);
16 0 $self->manager->connections->{$self->id} = $self;
17 0 weaken($self->{manager});
18 0 weaken($self->{connection});
19 0 return $self;
20 }
21  
22 sub send
23 0 ▶{
Subroutine send: not called CC=7 SCAR=40.3
Pod documented
24 0 my ($self, $message) = @_;
25 0 my $serializer = $self->manager->get_serializer;
26 0 ▶ my $is_inst = blessed $message && $message->isa("AnyEvent::WebSocket::Message");
Condition0%0/3
builtin::blessed($message) && $message->isa('AnyEvent::WebSocket::Message')
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($message) && $message->isa('AnyEvent::WebSocket::Message')
builtin::blessed($message) $message->isa('AnyEvent::WebSocket::Message')
Truth table0%0/3
A && B
A= builtin::blessed($message)B= $message->isa('AnyEvent::WebSocket::Message')
ABresult
0X0
100
111
27  
28 0 ▶ if ($serializer && (!blessed $message || !$is_inst)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($serializer and not builtin::blessed($message) && $is_inst) 0 0 0
Condition0%0/6
$serializer and not builtin::blessed($message) && $is_inst
!ll&&!rl&&r
000
builtin::blessed($message) && $is_inst
!ll&&!rl&&r
000
MC/DC0%0/3
$serializer and not builtin::blessed($message) && $is_inst
$serializer builtin::blessed($message) $is_inst
Truth table0%0/4
A and not(B && C)
A= $serializerB= builtin::blessed($message)C= $is_inst
ABCresult
0XX0
1110
10X1
1101
29 0 $message = $serializer->encode($message);
30 }
31  
32 0 ▶ if (ref $message && !$is_inst) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $message and not $is_inst) 0 0 0
Condition0%0/3
ref $message and not $is_inst
!ll&&!rl&&r
000
MC/DC0%0/2
ref $message and not $is_inst
ref $message not $is_inst
Truth table0%0/3
A and not(B)
A= ref $messageB= not $is_inst
ABresult
0X0
100
111
33 0 carp "invalid data sent to websocket peer, disconnecting";
34 0 $self->connection->close;
35 0 return;
36 }
37  
38 0 $self->connection->send($message);
39 }
40  
41 sub close
42 0 ▶{
Subroutine close: not called CC=1 SCAR=6.9
Pod documented
43 0 my ($self) = @_;
44 0 delete $self->manager->connections->{$self->id};
45 0 $self->connection->close;
46 }
47  
48 2 1;
49 __END__
↑ Summary AnyEvent.pm »