| 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
| |||||||||||||
| 22 | 5 | $content = decode_json $content; | |||||||||||
| 23 | |||||||||||||
| 24 | 5 | ▶ | if (exists $content->{multicast_id}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 67 | 0 | ▶ | $self->error ? 1 : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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)
MC/DC0%0/1
$self->content->{'results'} || (return)
$self->content->{'results'}
Truth table50%1/2
A
A= $self->content->{'results'}
| |||||||||||||
| 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; | |||||||||||