Net/OBEX/Packet/Request.pm

filter: Statementstmt 100% 60 / 60 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 23 / 23 Podpod 100% 2 / 2 totaltotal 97.7% 87 / 89 CC 4 SCAR 3.9
CC
4
Cov
97%
make
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« XML/OBEXFTP/FolderListing.pm ↑ Summary Net/OBEX/Response/Generic.pm »
1 package Net::OBEX::Packet::Request;
2  
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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Net::OBEX::Packet::Request::Connect;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Net::OBEX::Packet::Request::Disconnect;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Net::OBEX::Packet::Request::Get;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Net::OBEX::Packet::Request::Put;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Net::OBEX::Packet::Request::SetPath;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Net::OBEX::Packet::Request::Abort;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 our $VERSION = '1.001002'; # VERSION
15  
16 6 my %Valid_Packets = map { $_ => 1 }
17 qw(connect disconnect get put setpath abort);
18  
19 my %Make_Packet = (
20 1 ▶ connect => sub { _make_connect( shift ); },
Subroutine __ANON__: called CC=1 SCAR=0.0
21 1 ▶ disconnect => sub { _make_disconnect( shift ); },
Subroutine __ANON__: called CC=1 SCAR=0.0
22 1 ▶ get => sub { _make_get( shift ); },
Subroutine __ANON__: called CC=1 SCAR=0.0
23 1 ▶ put => sub { _make_put( shift ); },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 1 ▶ setpath => sub { _make_setpath( shift ); },
Subroutine __ANON__: called CC=1 SCAR=0.0
25 1 ▶ abort => sub { _make_abort( shift ); },
Subroutine __ANON__: called CC=1 SCAR=0.0
26 6 );
27  
28 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
29 3 my $class = shift;
30 3 return bless {}, $class;
31 }
32  
33 6 ▶sub make {
Subroutine make: called CC=4 SCAR=14.0
Pod documented
34 6 my $self = shift;
35  
36 6 ▶ croak "Must have even number of arguments to new()"
Branch: 1 branch
BranchTrueFalseTotal
if @_ & 1 0 6 6
37 if @_ & 1;
38  
39 6 my %args = @_;
40 6 $args{ +lc } = delete $args{ $_ } for keys %args;
41  
42 croak "Invalid packet name was specified (the `packet` argument)"
43 6 ▶ unless exists $Valid_Packets{ $args{packet} };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Valid_Packets{$args{"packet"}} 0 6 6
44  
45 6 my $make_ref = $Make_Packet{ $args{packet} };
46 6 delete $args{packet};
47 6 return $make_ref->( \%args );
48 }
49  
50 1 ▶sub _make_connect {
Subroutine _make_connect: called CC=1 SCAR=0.0
51 1 my $args = shift;
52 1 return Net::OBEX::Packet::Request::Connect->new( %$args )->make;
53 }
54  
55 1 ▶sub _make_disconnect {
Subroutine _make_disconnect: called CC=1 SCAR=0.0
56 1 my $args = shift;
57 1 return Net::OBEX::Packet::Request::Disconnect->new( %$args )->make;
58 }
59  
60 1 ▶sub _make_get {
Subroutine _make_get: called CC=1 SCAR=0.0
61 1 my $args = shift;
62 1 return Net::OBEX::Packet::Request::Get->new( %$args )->make;
63 }
64  
65 1 ▶sub _make_put {
Subroutine _make_put: called CC=1 SCAR=0.0
66 1 my $args = shift;
67 1 return Net::OBEX::Packet::Request::Put->new( %$args )->make;
68 }
69  
70 1 ▶sub _make_setpath {
Subroutine _make_setpath: called CC=1 SCAR=0.0
71 1 my $args = shift;
72 1 return Net::OBEX::Packet::Request::SetPath->new( %$args )->make;
73 }
74  
75 1 ▶sub _make_abort {
Subroutine _make_abort: called CC=1 SCAR=0.0
76 1 my $args = shift;
77 1 return Net::OBEX::Packet::Request::Abort->new( %$args )->make;
78 }
79  
80 6 1;
81  
82 __END__
« XML/OBEXFTP/FolderListing.pm ↑ Summary Net/OBEX/Response/Generic.pm »