blib/lib/Net/Azure/EventHubs/Response.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 81.5% 31 / 38 SCAR 14.1
CC
4
Cov
83%
as_hashref
4.9
BEGIN
1.0
BEGIN
1.0
CRAP 4.1
« blib/lib/Net/Azure/EventHubs.pm ↑ Summary blib/lib/Net/Azure/EventHubs/Request.pm »
1 package Net::Azure::EventHubs::Response;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use parent 'HTTP::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub as_hashref {
10 1 ▶ my $self = shift;
Subroutine as_hashref: called CC=4 SCAR=15.9
Pod documented
11 1 ▶ return if !$self->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_success 0 1 1
12  
13 1 my $type = $self->header('Content-Type');
14 1 ▶ if ($type && $type =~ /\Aapplication\/json/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type and $type =~ m[\Aapplication/json]) 0 1 1
Condition33%1/3
$type and $type =~ m[\Aapplication/json]
!ll&&!rl&&r
010
MC/DC0%0/2
$type and $type =~ m[\Aapplication/json]
$type $type =~ m[\Aapplication/json]
Truth table33%1/3
A and B
A= $typeB= $type =~ m[\Aapplication/json]
ABresult
0X0
100
111
15 0 return JSON->new->utf8(1)->decode($self->content);
16 }
17 1 return;
18 }
19  
20 7 1;
21  
22 =encoding utf-8
23  
24 =head1 NAME
25  
26 Net::Azure::EventHubs::Response - A Response Class for Net::Azure::EventHubs
27  
28 =head1 SYNOPSIS
29  
30 use Net::Azure::EventHubs::Request;
31 use LWP::UserAgent;
32 my $req = Net::Azure::EventHubs::Request->new(GET => 'http://...');
33 $req->agent(LWP::UserAgent->new);
34 my $res = $req->do;
35 my $json_data = $res->as_hashref;
36  
37 =head1 DESCRIPTION
38  
39 Net::Azure::EventHubs::Response is a response class for Net::Azure::EventHubs.
40  
41 It inherits HTTP::Response.
42  
43 =head1 METHODS
44  
45 =head2 as_hashref
46  
47 my $json_data = $res->as_hashref;
48  
49 Return a content data as hashref when content type is 'application/json'. Otherwise, undef is returned.
50  
51 =head1 LICENSE
52  
53 Copyright (C) ytnobody.
54  
55 This library is free software; you can redistribute it and/or modify
56 it under the same terms as Perl itself.
57  
58 =head1 AUTHOR
59  
60 ytnobody E<lt>ytnobody@gmail.comE<gt>
61  
62 =cut
63  
« blib/lib/Net/Azure/EventHubs.pm ↑ Summary blib/lib/Net/Azure/EventHubs/Request.pm »