blib/lib/SMS/Send/Nexmo.pm

filter: Statementstmt 48.7% 20 / 41 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 41.2% 26 / 63 CC 8 SCAR 31.1
CC
8
Cov
36%
new
42.0
send_sms
12.0
BEGIN
1.0
CRAP 22.5
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package SMS::Send::Nexmo;
4  
5 1 our $VERSION = '0.23';
6 # ABSTRACT: SMS::Send backend for the Nexmo.com SMS service.
7  
8 1 ▶use SMS::Send::Driver;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Nexmo::SMS;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @ISA = qw/SMS::Send::Driver/;
12 1 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
13 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
14 1 our @EXPORT = qw();
15  
16 1 our $URL = 'https://rest.nexmo.com/sms/json';
17  
18 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
19 0 my $pkg = shift;
20 0 my %p = @_;
21 0 ▶ exists $p{_username} or die $pkg."->new requires _username parameter\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $p{"_username"} or die $pkg . "->new requires _username parameter\n" 0 0 0
22 0 ▶ exists $p{_password} or die $pkg."->new requires _password parameter\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $p{"_password"} or die $pkg . "->new requires _password parameter\n" 0 0 0
23 0 ▶ exists $p{_from} or die $pkg."->new requires _from parameter\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $p{"_from"} or die $pkg . "->new requires _from parameter\n" 0 0 0
24 0 ▶ exists $p{_server} or $p{_server} = $URL;
Branch: 1 branch
BranchTrueFalseTotal
exists $p{"_server"} or $p{"_server"} = $SMS::Send::Nexmo::URL 0 0 0
25 0 ▶ exists $p{_verbose} or $p{_verbose} = 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $p{"_verbose"} or $p{"_verbose"} = 1 0 0 0
26 0 my $self = \%p;
27 0 bless $self, $pkg;
28 $self->{_nexmo} = Nexmo::SMS->new(
29 server => $p{_server},
30 username => $p{_username},
31 password => $p{_password},
32 0 );
33 0 return $self;
34 }
35  
36 0 ▶sub send_sms {
Subroutine send_sms: not called CC=3 SCAR=24.8
Pod documented
37 0 my $self = shift;
38 0 my %p = @_;
39 0 $p{to} =~ s/^\+//;
40 0 $p{to} =~ s/[- ]//g;
41  
42 my $sms = $self->{_nexmo}->sms(
43 text => $p{text},
44 from => $self->{_from},
45 to => $p{to},
46 0 );
47  
48 0 my $response = $sms->send;
49  
50 0 ▶ unless ($response->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->is_success) 0 0 0
51 0 ▶ warn "Failure: " . $sms->errstr . "\n" if ($self->{_verbose});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_verbose"} 0 0 0
52 0 return 0;
53 }
54 0 return 1;
55 }
56  
57 1 1;
58  
59 __END__
↑ Summary