blib/lib/Linux/Event/WebSocket/Client/_HTTPConnection.pm

filter: Statementstmt 73.6% 28 / 38 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 0.0% 0 / 3 totaltotal 57.9% 40 / 69 CC 7 SCAR 16.3
CC
7
Cov
59%
_websocket_state
12.0
data
12.0
on_drain
6.0
CRAP 5.1
« blib/lib/Linux/Event/WebSocket/Server.pm ↑ Summary blib/lib/Linux/Event/WebSocket/Connection.pm »
1 package Linux::Event::WebSocket::Client::_HTTPConnection;
2 6 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use parent 'Linux::Event::HTTP::Client::Connection';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶use Linux::Event::Framer ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Linux::Event::WebSocket::_BQ ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 67 ▶sub can ($class, $name) {
Subroutine can: called CC=2 SCAR=6.9
Pod undocumented
15 67 ▶ return undef if $name eq 'on_data';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "on_data" 5 62 67
16 62 return UNIVERSAL::can($class, $name);
17 }
18  
19 7 ▶sub _websocket_http_input ($self, $bytes) {
Subroutine _websocket_http_input: called CC=1 SCAR=0.0
20 7 return Linux::Event::HTTP::Client::Connection::on_data($self, $bytes);
21 }
22  
23 6 Linux::Event::Framer->declare_native_consumer(
24 __PACKAGE__,
25 Linux::Event::WebSocket::_BQ->http_bridge_consumer_definition,
26 );
27  
28 0 ▶sub _websocket_state ($self) {
Subroutine _websocket_state: not called CC=3 SCAR=24.8
29 0 my $state = $self->SUPER::data;
30 0 ▶ croak 'WebSocket client connection state is unavailable'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($state) and $state->isa("Linux::Event::WebSocket::_State") 0 0 0
Condition0%0/3
builtin::blessed($state) and $state->isa("Linux::Event::WebSocket::_State")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($state) and $state->isa("Linux::Event::WebSocket::_State")
builtin::blessed($state) $state->isa("Linux::Event::WebSocket::_State")
Truth table0%0/3
A and B
A= builtin::blessed($state)B= $state->isa("Linux::Event::WebSocket::_State")
ABresult
0X0
100
111
31 if !blessed($state)
32 || !$state->isa('Linux::Event::WebSocket::_State');
33 0 return $state;
34 }
35  
36 0 ▶sub data ($self, @value) {
Subroutine data: not called CC=3 SCAR=24.8
Pod undocumented
37 0 my $state = $self->_websocket_state;
38 0 ▶ croak 'data() accepts at most one value' if @value > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @value > 1 0 0 0
39 0 ▶ $state->{data} = $value[0] if @value;
Branch: 1 branch
BranchTrueFalseTotal
if @value 0 0 0
40 0 return $state->{data};
41 }
42  
43 # HTTP Client::Connection captures this method as its user drain handler and
44 # keeps that constructor override through transition_to(). Forward it after the
45 # same object becomes a WebSocket connection.
46 0 ▶sub on_drain ($self) {
Subroutine on_drain: not called CC=2 SCAR=17.9
Pod undocumented
47 0 ▶ if ($self->isa('Linux::Event::WebSocket::Connection')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("Linux::Event::WebSocket::Connection")) 0 0 0
48 0 Linux::Event::WebSocket::Connection::on_drain($self);
49 }
50 0 return;
51 }
52  
53 6 1;
« blib/lib/Linux/Event/WebSocket/Server.pm ↑ Summary blib/lib/Linux/Event/WebSocket/Connection.pm »