blib/lib/Danga/Socket/Callback.pm

filter: Statementstmt 36.8% 14 / 38 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 100% 5 / 5 totaltotal 33.8% 23 / 68 CC 10 SCAR 28.3
CC
10
Cov
26%
new
42.0
event_read
6.0
event_write
6.0
CRAP 16.9
↑ Summary
1 package Danga::Socket::Callback;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(Danga::Socket);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use fields qw(on_read_ready on_write_ready on_error on_signal_hup context);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.013';
8  
9 sub new
10 0 ▶{
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
11 0 my Danga::Socket::Callback $self = shift;
12 0 my %args = @_;
13 0 ▶ $self = fields::new($self) unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
14 0 $self->SUPER::new($args{handle});
15  
16 0 foreach my $field (qw(on_read_ready on_write_ready on_error on_signal_hup context)) {
17 0 ▶ $self->{$field} = $args{$field} if $args{$field}
Branch: 1 branch
BranchTrueFalseTotal
if $args{$field} 0 0 0
18 }
19  
20 0 ▶ if ($self->{on_read_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"on_read_ready"}) 0 0 0
21 0 $self->watch_read(1);
22 }
23  
24 0 ▶ if ($self->{on_write_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"on_write_ready"}) 0 0 0
25 0 $self->watch_write(1);
26 }
27  
28 0 return $self;
29 }
30  
31 sub event_read
32 0 ▶{
Subroutine event_read: not called CC=2 SCAR=17.9
Pod documented
33 0 my Danga::Socket::Callback $self = shift;
34 0 ▶ if (my $code = $self->{on_read_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $self->{"on_read_ready"}) 0 0 0
35 0 return $code->($self);
36 }
37 }
38  
39 sub event_write
40 0 ▶{
Subroutine event_write: not called CC=2 SCAR=17.9
Pod documented
41 0 my Danga::Socket::Callback $self = shift;
42 0 ▶ if (my $code = $self->{on_write_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $self->{'on_write_ready'}) { } 0 0 0
43 0 return $code->($self);
44 } else {
45 0 $self->SUPER::event_write();
46 }
47 }
48  
49 sub event_hup
50 0 ▶{
Subroutine event_hup: not called CC=2 SCAR=17.9
Pod documented
51 0 my Danga::Socket::Callback $self = shift;
52 0 ▶ if (my $code = $self->{on_signal_hup}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $self->{"on_signal_hup"}) 0 0 0
53 0 return $code->($self);
54 }
55 }
56  
57 sub event_err
58 0 ▶{
Subroutine event_err: not called CC=2 SCAR=17.9
Pod documented
59 0 my Danga::Socket::Callback $self = shift;
60 0 ▶ if (my $code = $self->{on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $self->{"on_error"}) 0 0 0
61 0 $code->($self);
62 }
63 }
64  
65 1 1;
66  
67 __END__
↑ Summary