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

filter: Statementstmt 100% 32 / 32 Branchbran 100% 6 / 6 Conditioncond 86.6% 13 / 15 MC/DCmcdc 62.5% 5 / 8 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 93.0% 67 / 72 SCAR 22.0
CC
9
Cov
96%
new
8.0
send
2.0
BEGIN
1.0
CRAP 9.0
« blib/lib/WWW/FCM/HTTP/V1/OAuth.pm ↑ Summary Build »
1 package WWW::FCM::HTTP::V1;
2 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
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  
6 3 our $VERSION = "0.01";
7  
8 use Class::Accessor::Lite (
9 3 new => 0,
10 rw => [qw/sender api_url/],
11 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use JSON qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use WWW::FCM::HTTP::V1::OAuth;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 our $SCOPE_FIREBASE_MESSAGING = "https://www.googleapis.com/auth/firebase.messaging";
18  
19 sub new {
20 7 ▶ my $class = shift;
Subroutine new: called CC=8 SCAR=20.8
Pod documented
21 7 ▶ my %args = $_[0] && ref $_[0] eq 'HASH' ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] && ref $_[0] eq 'HASH' ? : 1 6 7
Condition100%3/3
$_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
151
MC/DC100%2/2
$_[0] and ref $_[0] eq "HASH"
$_[0] ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
22 croak 'Usage: WWW::FCM::HTTP::V1->new({ api_url => $api_url, api_key_json => $api_key_json })'
23 7 ▶ unless (exists $args{api_url} && defined $args{api_url} && exists $args{api_key_json} && defined $args{api_key_json});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"} and defined $args{"api_key_json"} 1 4 5
Condition88%8/9
exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"} and defined $args{"api_key_json"}
!ll&&!rl&&r
214
exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"}
!ll&&!rl&&r
205
exists $args{"api_url"} and defined $args{"api_url"}
!ll&&!rl&&r
115
MC/DC75%3/4
exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"} and defined $args{"api_key_json"}
exists $args{"api_url"} defined $args{"api_url"} exists $args{"api_key_json"} defined $args{"api_key_json"}
Truth table80%4/5
A and B and C and D
A= exists $args{"api_url"}B= defined $args{"api_url"}C= exists $args{"api_key_json"}D= defined $args{"api_key_json"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
24  
25 $args{sender} ||= WWW::FCM::HTTP::V1::OAuth->new(
26 api_key_json => $args{api_key_json},
27 4 ▶ scopes => [$SCOPE_FIREBASE_MESSAGING],
Condition66%2/3
$args{"sender"} ||= "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
l!l&&r!l&&!r
130
MC/DC0%0/2
$args{"sender"} ||= "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
$args{"sender"} "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
Truth table66%2/3
A ||= B
A= $args{"sender"}B= "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
ABresult
1X1
011
000
28 );
29  
30 4 bless { %args }, $class;
31 }
32  
33 sub send {
34 8 ▶ my ($self, $content) = @_;
Subroutine send: called CC=2 SCAR=6.9
Pod documented
35 8 ▶ croak 'Usage: $fcm->send(\%content)' unless ref $content eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $content eq "HASH" 4 4 8
36  
37 4 $self->sender->request(
38 method => "POST",
39 uri => $self->api_url,
40 content => encode_json($content),
41 );
42 }
43  
44 3 1;
45 __END__
« blib/lib/WWW/FCM/HTTP/V1/OAuth.pm ↑ Summary Build »