Net/OBEX/Response.pm

filter: Statementstmt 70.4% 31 / 44 Branchbran 20.0% 2 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 66.6% 44 / 66 CC 6 SCAR 24.4
CC
6
Cov
61%
parse_sock
30.0
parse
2.0
BEGIN
1.0
CRAP 11.5
« Net/OBEX/FTP.pm ↑ Summary Net/OBEX/Packet/Headers/Base.pm »
1 package Net::OBEX::Response;
2  
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 our $VERSION = '1.001002'; # VERSION
7  
8 6 ▶use Net::OBEX::Response::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Net::OBEX::Response::Connect;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Net::OBEX::Packet::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 ▶use base 'Class::Data::Accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 __PACKAGE__->mk_classaccessors( qw(obj_connect obj_generic obj_head error ) );
14  
15 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
16 3 my $class = shift;
17 3 my $self = bless {}, $class;
18 3 $self->obj_connect( Net::OBEX::Response::Connect->new );
19 3 $self->obj_generic( Net::OBEX::Response::Generic->new );
20 3 $self->obj_head( Net::OBEX::Packet::Headers->new );
21  
22 3 return $self;
23 }
24  
25 2 ▶sub parse {
Subroutine parse: called CC=2 SCAR=6.9
Pod documented
26 2 my ( $self, $packet, $is_connect ) = @_;
27  
28 2 ▶ if ( $is_connect ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_connect) { } 1 1 2
29 1 return $self->obj_connect->parse_info( $packet );
30 }
31 else {
32 1 return $self->obj_generic->parse_info( $packet );
33 }
34 }
35  
36 0 ▶sub parse_sock {
Subroutine parse_sock: not called CC=5 SCAR=34.0
Pod documented
37 0 my ( $self, $sock, $is_connect ) = @_;
38  
39 0 my $read_buffer;
40 0 ▶ unless ( $sock->read( $read_buffer, ( $is_connect ? 7 : 3 ) ) ) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($sock->read($read_buffer, $is_connect ? 7 : 3)) 0 0 0
$is_connect ? : 0 0 0
41 0 $self->error( 'Socket error: ' . $sock->error );
42 0 return;
43 }
44  
45 0 my %response = (
46 raw_packet => $read_buffer,
47 info => $self->parse( $read_buffer, $is_connect ),
48 );
49  
50 0 ▶ if ( my $length = $response{info}{headers_length} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $length = $response{"info"}{"headers_length"}) 0 0 0
51 0 ▶ unless ( $sock->read( $read_buffer, $length ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sock->read($read_buffer, $length)) 0 0 0
52 0 $self->error( 'Socket error: ' . $sock->error );
53 0 return;
54 }
55 0 $response{raw_packet} .= $read_buffer;
56 0 $response{headers} = $self->obj_head->parse( $read_buffer );
57 }
58  
59 0 return \%response;
60 }
61  
62 6 1;
63  
64 __END__
« Net/OBEX/FTP.pm ↑ Summary Net/OBEX/Packet/Headers/Base.pm »