lib/PagSeguro/API/Notification.pm

filter: Statementstmt 72.0% 18 / 25 Branchbran 31.2% 5 / 16 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 54.3% 31 / 57 CC 11 SCAR 23.1
CC
11
Cov
52%
load
16.1
_code_uri
12.0
new
3.2
CRAP 10.1
« lib/PagSeguro/API/Base.pm ↑ Summary blib/lib/PagSeguro/API/Transaction.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=3 SCAR=11.7
Pod documented
10 2 ▶ my %args = @_ if ( @_ % 2 ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 == 0 2 0 2
11  
12 return bless {
13 2 ▶ _context => ($args->{context})? $args->{context} : $args,
Branch: 1 branch
BranchTrueFalseTotal
$args->{'context'} ? : 0 2 2
14 _notification => undef,
15 }, $class;
16 }
17  
18 # methods
19 sub load {
20 1 ▶ my $self = shift;
Subroutine load: called CC=7 SCAR=27.8
Pod documented
21  
22 1 my %args;
23 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
24  
25 1 ▶ if ( %args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (%args) 1 0 1
26 # parse and return by file
27 1 ▶ return XMLin( $args{file} ) if $args{file};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"file"} 1 0 1
28 }
29  
30 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
31
32 # debug
33 warn "[Debug] Notification Response: $response\n"
34 0 ▶ if $ENV{PAGSEGURO_API_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGSEGURO_API_DEBUG"} 0 0 0
35  
36 0 return XMLin($response);
37 }
38  
39 sub _code_uri {
40 0 ▶ my ( $self, $code ) = @_;
Subroutine _code_uri: not called CC=3 SCAR=24.8
41  
42 my $uri = join '',
43 (
44 $self->_context->resource(
45 0 ▶ ( $ENV{PAGSEGURO_API_SANDBOX} ? 'SANDBOX_URI' : 'BASE_URI' )
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PAGSEGURO_API_SANDBOX'} ? : 0 0 0
46 ),
47 $self->_context->resource('TRANSACTION'),
48 $self->_context->resource('NOTIFICATIONS'),
49 "${code}",
50 "?email=" . $self->_context->email,
51 "&token=" . $self->_context->token,
52 );
53  
54 0 ▶ warn "[Debug] URI: $uri\n" if $ENV{PAGSEGURO_API_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PAGSEGURO_API_DEBUG"} 0 0 0
55 0 return $uri;
56 }
57  
58 6 1;
59 __END__
« lib/PagSeguro/API/Base.pm ↑ Summary blib/lib/PagSeguro/API/Transaction.pm »