lib/PagSeguro/API/Notification.pm

filter: Statementstmt 72.0% 18 / 25 Branchbran 28.5% 4 / 14 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 52.4% 32 / 61 SCAR 33.3
CC
12
Cov
52%
load
16.1
_code_uri
12.0
new
4.6
CRAP 27.8
« lib/PagSeguro/API.pm ↑ Summary lib/PagSeguro/API/Base.pm »
1 package PagSeguro::API::Notification;
2 6 ▶use base 'PagSeguro::API::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 6 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # constructor
8 sub new {
9 2 ▶ my $class = shift;
Subroutine new: called CC=4 SCAR=15.2
Pod documented
10 2 ▶ my %args = @_ if ( @_ % 2 ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 == 0 2 0 2
11  
12 return bless {
13 email => $args{email} || undef,
14 token => $args{token} || undef,
15  
16 2 ▶ _notification => undef,
Condition50%2/4
$args{'email'} || undef
l!l
20
$args{'token'} || undef
l!l
20
MC/DC0%0/1
$args{'email'} || undef
$args{'email'}
MC/DC0%0/1
$args{'token'} || undef
$args{'token'}
Truth table50%1/2
A
A= $args{'email'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'token'}
Aresult
11
00
17 }, $class;
18 }
19  
20 # methods
21 sub load {
22 1 ▶ my $self = shift;
Subroutine load: called CC=7 SCAR=27.8
Pod documented
23  
24 1 my %args;
25 1 ▶ $args{file} = $_[1] if $_[0] && $_[1];
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] and $_[1] 1 0 1
Condition33%1/3
$_[0] and $_[1]
!ll&&!rl&&r
001
MC/DC0%0/2
$_[0] and $_[1]
$_[0] $_[1]
Truth table33%1/3
A and B
A= $_[0]B= $_[1]
ABresult
0X0
100
111
26  
27 1 ▶ if ( %args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (%args) 1 0 1
28 # parse and return by file
29 1 ▶ return XMLin( $args{file} ) if $args{file};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"file"} 1 0 1
30 }
31  
32 0 ▶ my $response = get $self->_code_uri( $_[0] ) || '';
Condition0%0/2
&get(scalar $self->_code_uri($_[0])) || ''
l!l
00
MC/DC0%0/1
&get(scalar $self->_code_uri($_[0])) || ''
&get(scalar $self->_code_uri($_[0]))
Truth table0%0/2
A
A= &get(scalar $self->_code_uri($_[0]))
Aresult
11
00
33
34 # debug
35 warn "[Debug] Notification Response: $response\n"
36 0 ▶ if $ENV{PAGSEGURO_API_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGSEGURO_API_DEBUG"} 0 0 0
37  
38 0 return XMLin($response);
39 }
40  
41 sub _code_uri {
42 0 ▶ my ( $self, $code ) = @_;
Subroutine _code_uri: not called CC=3 SCAR=24.8
43  
44 my $uri = join '',
45 (
46 $self->resource(
47 ( $ENV{PAGSEGURO_API_SANDBOX} ? 'SANDBOX_URI' : 'BASE_URI' )
48 ),
49 $self->resource('TRANSACTION'),
50 $self->resource('NOTIFICATIONS'),
51 "${code}",
52 "?email=" . $self->{email},
53 "&token=" . $self->{token},
54 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PAGSEGURO_API_SANDBOX'} ? : 0 0 0
55  
56 0 ▶ warn "[Debug] URI: $uri\n" if $ENV{PAGSEGURO_API_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGSEGURO_API_DEBUG"} 0 0 0
57 0 return $uri;
58 }
59  
60 6 1;
61 __END__
« lib/PagSeguro/API.pm ↑ Summary lib/PagSeguro/API/Base.pm »