Common/Procedure/Call/Version_1_1.pm

filter: Statementstmt 93.8% 46 / 49 Branchbran 70.0% 7 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 91.6% 11 / 12 Podpod 60.0% 3 / 5 totaltotal 86.4% 70 / 81 CC 7 SCAR 9.0
CC
7
Cov
89%
BUILDARGS
4.2
deflate_params
4.2
__ANON__
2.0
CRAP 2.5
« Common/Procedure/Return/Version_1_1/Error.pm ↑ Summary Common/Procedure/Return.pm »
1 #!/usr/bin/perl
2  
3 package JSON::RPC::Common::Procedure::Call::Version_1_1;
4 2 $JSON::RPC::Common::Procedure::Call::Version_1_1::VERSION = '0.11';
5 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: JSON-RPC 1.1 Procedure Call
7  
8 2 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use JSON::RPC::Common::TypeConstraints qw(JSONContainer);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use JSON::RPC::Common::Procedure::Return::Version_1_1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶use namespace::clean -except => [qw(meta)];
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 extends qw(JSON::RPC::Common::Procedure::Call);
19  
20 34 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=4 SCAR=14.2
Pod documented
21 34 my ( $self, @args ) = @_;
22  
23 34 my $params = $self->next::method(@args);
24  
25 34 ▶ if ( exists $params->{kwparams} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params->{"kwparams"}) 1 33 34
26 1 ▶ if ( exists $params->{params} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params->{'params'}) { } 0 1 1
27 0 croak "params and kwparams are mutually exclusive";
28 } else {
29 1 $params->{params} = delete $params->{kwparams};
30 }
31  
32 1 ▶ $params->{alt_spec} = 1 unless exists $params->{alt_spec};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params->{"alt_spec"} 1 0 1
33 }
34  
35 34 return $params;
36 }
37  
38 has '+version' => (
39 # default => "1.1", # broken, Moose::Meta::Method::Accessor gens numbers if looks_like_number
40 0 ▶ default => sub { "1.1" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 2 );
42  
43 2 has alt_spec => (
44 isa => "Bool",
45 is => "rw",
46 default => 0,
47 );
48  
49 2 has '+params' => (
50 isa => JSONContainer,
51 );
52  
53 2 has '+return_class' => (
54 default => "JSON::RPC::Common::Procedure::Return::Version_1_1",
55 );
56  
57 2 has '+return_class' => (
58 default => "JSON::RPC::Common::Procedure::Return::Version_1_1",
59 );
60  
61 2 has '+error_class' => (
62 default => "JSON::RPC::Common::Procedure::Return::Version_1_1::Error",
63 );
64  
65 3 ▶sub is_notification { 0 }
Subroutine is_notification: called CC=1 SCAR=0.0
Pod documented
66  
67 1 ▶sub is_service {
Subroutine is_service: called CC=1 SCAR=0.0
Pod documented
68 1 my $self = shift;
69 1 $self->method =~ /^system\./;
70 }
71  
72 85 ▶sub deflate_version {
Subroutine deflate_version: called CC=1 SCAR=0.0
Pod undocumented
73 85 my $self = shift;
74 85 return ( version => $self->version ) ;
75 }
76  
77 85 ▶sub deflate_params {
Subroutine deflate_params: called CC=4 SCAR=14.2
Pod undocumented
78 85 my $self = shift;
79  
80 85 ▶ if ( $self->has_params ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_params) { } 85 0 85
81 85 my $params = $self->params;
82  
83 # JSON-RPC 1.1 alt specifies that named params go in kwparams. YUCK!
84 85 ▶ if ( ref($params) eq 'HASH' and $self->alt_spec ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $params eq "HASH" and $self->alt_spec) 1 84 85
Condition66%2/3
ref $params eq "HASH" and $self->alt_spec
!ll&&!rl&&r
0841
MC/DC50%1/2
ref $params eq "HASH" and $self->alt_spec
ref $params eq "HASH" $self->alt_spec
Truth table66%2/3
A and B
A= ref $params eq "HASH"B= $self->alt_spec
ABresult
0X0
100
111
85 1 return ( kwparams => $params );
86 }
87  
88 84 return ( params => $params );
89 } else {
90 0 return ();
91 }
92 }
93  
94 2 __PACKAGE__->meta->make_immutable;
95  
96 2 __PACKAGE__
97  
98 __END__
« Common/Procedure/Return/Version_1_1/Error.pm ↑ Summary Common/Procedure/Return.pm »