API/Distribution.pm

filter: Statementstmt 100% 33 / 33 Branchbran 90.0% 9 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 90.9% 50 / 55 CC 7 SCAR 15.1
CC
7
Cov
93%
distribution
7.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« API/Source.pm ↑ Summary API/File.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::Distribution;
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 # /distribution/{distribution}
12 5 ▶sub distribution {
Subroutine distribution: called CC=7 SCAR=19.5
Pod documented
13 5 my $self = shift;
14 5 my $url = '';
15 5 my $error = "Either provide a distribution or 'search'";
16  
17 5 my %extra_opts = ();
18  
19 5 ▶ if ( @_ == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 1 4 5
elsif (@_) { } 3 1 4
20 1 $url = 'distribution/' . shift;
21 } elsif ( @_ ) {
22 3 my %opts = @_;
23  
24 3 ▶ if ( defined ( my $dist = $opts{'distribution'} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $dist = $opts{'distribution'})) { } 1 2 3
elsif (defined(my $search_opts = $opts{'search'})) { } 1 1 2
25 1 $url = "distribution/$dist";
26 } elsif ( defined ( my $search_opts = $opts{'search'} ) ) {
27 1 ▶ croak $error
Branch: 1 branch
BranchTrueFalseTotal
unless ref $search_opts and ref $search_opts eq "HASH" 0 1 1
Condition33%1/3
ref $search_opts and ref $search_opts eq "HASH"
!ll&&!rl&&r
001
MC/DC0%0/2
ref $search_opts and ref $search_opts eq "HASH"
ref $search_opts ref $search_opts eq "HASH"
Truth table33%1/3
A and B
A= ref $search_optsB= ref $search_opts eq "HASH"
ABresult
0X0
100
111
28 unless ref $search_opts && ref $search_opts eq 'HASH';
29  
30 1 %extra_opts = %{$search_opts};
31 1 $url = 'distribution/_search';
32 } else {
33 1 croak $error;
34 }
35 } else {
36 1 croak $error;
37 }
38  
39 3 return $self->fetch( $url, %extra_opts );
40 }
41  
42 17 1;
43  
44 __END__
« API/Source.pm ↑ Summary API/File.pm »