API/Rating.pm

filter: Statementstmt 78.7% 26 / 33 Branchbran 50.0% 5 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 69.0% 38 / 55 CC 7 SCAR 21.3
CC
7
Cov
67%
rating
13.8
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« API/Author.pm ↑ Summary API/Release.pm »
1 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MetaCPAN::API::Rating;
4  
5 17 our $VERSION = '0.52';
6  
7 17 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # /rating/{id}
12 # /rating/_search
13 2 ▶sub rating {
Subroutine rating: called CC=7 SCAR=26.2
Pod documented
14 2 my $self = shift;
15 2 my $url = '';
16 2 my $error = "Either provide 'id' or 'search'";
17  
18 2 my %extra_opts = ();
19  
20 2 ▶ if ( @_ == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 0 2 2
elsif (@_) { } 1 1 2
21 0 $url = 'rating/' . shift;
22 } elsif ( @_ ) {
23 1 my %opts = @_;
24  
25 1 ▶ if ( defined ( my $id = $opts{'id'} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $id = $opts{'id'})) { } 0 1 1
elsif (defined(my $search_opts = $opts{'search'})) { } 0 1 1
26 0 $url = "rating/$id";
27 } elsif ( defined ( my $search_opts = $opts{'search'} ) ) {
28 0 ▶ croak $error
Branch: 1 branch
BranchTrueFalseTotal
unless ref $search_opts and ref $search_opts eq "HASH" 0 0 0
Condition0%0/3
ref $search_opts and ref $search_opts eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $search_opts and ref $search_opts eq "HASH"
ref $search_opts ref $search_opts eq "HASH"
Truth table0%0/3
A and B
A= ref $search_optsB= ref $search_opts eq "HASH"
ABresult
0X0
100
111
29 unless ref $search_opts && ref $search_opts eq 'HASH';
30  
31 0 %extra_opts = %{$search_opts};
32 0 $url = 'rating/_search';
33 } else {
34 1 croak $error;
35 }
36 } else {
37 1 croak $error;
38 }
39  
40 0 return $self->fetch( $url, %extra_opts );
41 }
42  
43 17 1;
44  
45 __END__
« API/Author.pm ↑ Summary API/Release.pm »