blib/lib/WWW/FCM/HTTP/Response.pm

filter: Statementstmt 94.1% 48 / 51 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 89.4% 17 / 19 Podpod 0.0% 0 / 9 totaltotal 77.7% 70 / 90 CC 6 SCAR 10.0
CC
6
Cov
87%
has_error
12.0
new
3.0
results
2.0
CRAP 2.7
↑ Summary blib/lib/WWW/FCM/HTTP.pm »
1 package WWW::FCM::HTTP::Response;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use JSON qw(decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 use Class::Accessor::Lite (
7 3 new => 0,
8 ro => [qw/http_response content is_success sent_reg_ids/],
9 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use WWW::FCM::HTTP::Response::ResultSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 6 ▶ my ($class, $http_response) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
15  
16 6 my $is_success = $http_response->is_success;
17 6 my $content = $http_response->content;
18 6 my $req_content = decode_json($http_response->request->content);
19  
20 6 my $sent_reg_ids = [];
21 6 ▶ if ($is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_success) { } 5 1 6
22 5 $content = decode_json $content;
23  
24 5 ▶ if (exists $content->{multicast_id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $content->{"multicast_id"}) 4 1 5
25 4 $sent_reg_ids = $req_content->{registration_ids};
26 }
27 }
28 else {
29 1 $content = { error => $content };
30 }
31  
32 6 bless {
33 is_success => $is_success,
34 content => $content,
35 sent_reg_ids => $sent_reg_ids,
36 http_response => $http_response,
37 }, $class;
38 }
39  
40 sub success {
41 6 ▶ shift->content->{success};
Subroutine success: called CC=1 SCAR=0.0
Pod undocumented
42 }
43  
44 sub failure {
45 6 ▶ shift->content->{failure};
Subroutine failure: called CC=1 SCAR=0.0
Pod undocumented
46 }
47  
48 sub message_id {
49 6 ▶ shift->content->{message_id};
Subroutine message_id: called CC=1 SCAR=0.0
Pod undocumented
50 }
51  
52 sub multicast_id {
53 6 ▶ shift->content->{multicast_id};
Subroutine multicast_id: called CC=1 SCAR=0.0
Pod undocumented
54 }
55  
56 sub canonical_ids {
57 6 ▶ shift->content->{canonical_ids};
Subroutine canonical_ids: called CC=1 SCAR=0.0
Pod undocumented
58 }
59  
60 sub error {
61 6 ▶ shift->content->{error};
Subroutine error: called CC=1 SCAR=0.0
Pod undocumented
62 }
63  
64 sub has_error {
65 0 ▶ my $self = shift;
Subroutine has_error: not called CC=3 SCAR=24.8
Pod undocumented
66 0 ▶ return 1 unless $self->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_success 0 0 0
67 0 ▶ $self->error ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->error ? : 0 0 0
68 }
69  
70 sub results {
71 4 ▶ my $self = shift;
Subroutine results: called CC=2 SCAR=7.1
Pod undocumented
72 4 ▶ my $results = $self->content->{results} || return;
Condition50%1/2
$self->content->{'results'} || (return)
l!l
40
MC/DC0%0/1
$self->content->{'results'} || (return)
$self->content->{'results'}
Truth table50%1/2
A
A= $self->content->{'results'}
Aresult
11
00
73 4 WWW::FCM::HTTP::Response::ResultSet->new($results, $self->sent_reg_ids);
74 }
75  
76 ▶sub DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
77 sub AUTOLOAD {
78 1 ▶ (my $method = our $AUTOLOAD) =~ s/.*:://;
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
79 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
80 1 *{$AUTOLOAD} = sub {
81 3 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 6 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
83 6 $self->{http_response}->$method(@_);
84 1 };
85 1 goto &$AUTOLOAD;
86 }
87  
88 3 1;
↑ Summary blib/lib/WWW/FCM/HTTP.pm »