blib/lib/OpenData/ShortNumberInfo.pm

filter: Statementstmt 54.8% 17 / 31 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 57.5% 23 / 40 CC 2 SCAR 8.1
CC
2
Cov
52%
name
5.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
↑ Summary
1 package OpenData::ShortNumberInfo;
2 # ABSTRACT: Perl interface to OpenData ShortNumberInfo web service
3  
4  
5 1 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 class OpenData::ShortNumberInfo {
9 1 ▶ use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶ use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶ use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 field $number :param //= 103;
14  
15 # TODO: accessor $name
16  
17  
18 0 ▶ method name ( $number ) {
Subroutine name: not called CC=2 SCAR=16.7
Pod documented
19 # Construct API URL
20 0 my $uri = URI -> new( 'https://api.opendata.az' );
21 0 $uri -> path_segments(
22 'v1', # version
23 'json', # format
24 'nrytn', # organization
25 'ShortNumberInfo', # service
26 $number # parameter
27 );
28  
29 # Issue HTTP request to get the web page
30 0 my $http = HTTP::Tiny -> new();
31 0 my $response = $http -> get( $uri ); # RV: HR
32  
33 # Convert JSON from HTTP response into Perl hash
34 0 my $json = JSON -> new();
35 0 my $content = $json -> decode( $response -> {content} );
36  
37 0 ▶ unless ( defined( $content -> {StatusMessage} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $content->{'StatusMessage'}) { } 0 0 0
38 0 return $content -> {Response} -> [0] -> {Name};
39 }
40 else {
41 0 STDERR -> say( $content -> {StatusMessage} );
42 0 exit 2;
43 }
44 1 }
45 }
46  
47 1 __END__
↑ Summary