NotificationHubs/Response.pm

filter: Statementstmt 75.0% 18 / 24 Branchbran 0.0% 0 / 4 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 57.7% 26 / 45 CC 5 SCAR 20.9
CC
5
Cov
58%
as_hashref
20.0
new
2.1
BEGIN
1.0
CRAP 8.1
↑ Summary NotificationHubs.pm »
1 package Net::Azure::NotificationHubs::Response;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Class::Accessor::Lite (
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ro => [qw[status reason headers content success]],
9 new => 0
10 6 );
11  
12 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
13 1 my ($class, $status, $reason, $headers, $content, $success) = @_;
14 1 ▶ bless {
Condition50%1/2
$headers || {}
l!l
10
MC/DC0%0/1
$headers || {}
$headers
Truth table50%1/2
A
A= $headers
Aresult
11
00
15 status => $status,
16 reason => $reason,
17 headers => $headers || {},
18 content => $content,
19 success => $success,
20 }, $class;
21 }
22  
23 0 ▶sub as_hashref {
Subroutine as_hashref: not called CC=4 SCAR=30.0
Pod documented
24 0 my $self = shift;
25 0 ▶ return if !$self->success;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->success 0 0 0
26
27 0 my $type = $self->headers->{'content-type'};
28  
29 0 ▶ if ($type && $type =~ /\Aapplication\/json/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type and $type =~ m[\Aapplication/json]) 0 0 0
Condition0%0/3
$type and $type =~ m[\Aapplication/json]
!ll&&!rl&&r
000
MC/DC0%0/2
$type and $type =~ m[\Aapplication/json]
$type $type =~ m[\Aapplication/json]
Truth table0%0/3
A and B
A= $typeB= $type =~ m[\Aapplication/json]
ABresult
0X0
100
111
30 0 return JSON->new->utf8(1)->decode($self->{content});
31 }
32 0 return;
33 }
34
35 6 1;
36  
37 =encoding utf-8
38  
39 =head1 NAME
40  
41 Net::Azure::NotificationHubs::Response - A Response Class for Net::Azure::NotificationHubs
42  
43 =head1 SYNOPSIS
44  
45 use Net::Azure::NotificationHubs::Request;
46 use HTTP::Tiny;
47 my $req = Net::Azure::NotificationHubs::Request->new(GET => 'http://...');
48 $req->agent(HTTP::Tiny->new);
49 my $res = $req->do;
50 my $json_data = $res->as_hashref;
51  
52 =head1 DESCRIPTION
53  
54 Net::Azure::NotificationHubs::Response is a response class for Net::Azure::NotificationHubs.
55  
56 It inherits HTTP::Response.
57  
58 =head1 METHODS
59  
60 =head2 as_hashref
61  
62 my $json_data = $res->as_hashref;
63  
64 Return a content data as hashref when content type is 'application/json'. Otherwise, undef is returned.
65  
66 =head1 LICENSE
67  
68 Copyright (C) ytnobody.
69  
70 This library is free software; you can redistribute it and/or modify
71 it under the same terms as Perl itself.
72  
73 =head1 AUTHOR
74  
75 ytnobody E<lt>ytnobody@gmail.comE<gt>
76  
77 =cut
↑ Summary NotificationHubs.pm »