lib/PagSeguro/API.pm

filter: Statementstmt 100% 44 / 44 Branchbran 62.5% 20 / 32 Conditioncond 53.8% 14 / 26 MC/DCmcdc 25.0% 4 / 16 Subroutinesub 100% 11 / 11 Podpod 100% 6 / 6 totaltotal 73.3% 99 / 135 SCAR 36.0
CC
27
Cov
76%
new
10.2
notification
8.5
transaction
7.6
CRAP 36.5
« lib/PagSeguro/API/Transaction.pm ↑ Summary lib/PagSeguro/API/Notification.pm »
1 package PagSeguro::API;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 our $VERSION = '0.004';
5  
6 6 ▶use PagSeguro::API::Checkout;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use PagSeguro::API::Transaction;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use PagSeguro::API::Notification;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # constructor
11 sub new {
12 12 ▶ my $class = shift;
Subroutine new: called CC=10 SCAR=23.2
Pod documented
13 12 ▶ my %args = @_ if (@_ % 2) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 == 0 12 0 12
14  
15 # start resource
16 12 PagSeguro::API::Resource->instance;
17  
18 # check env vars
19 $args{email} = $ENV{PAGSEGURO_API_EMAIL} || undef
20 12 ▶ unless $args{email};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"email"} 2 10 12
Condition100%2/2
$ENV{'PAGSEGURO_API_EMAIL'} || undef
l!l
11
MC/DC100%1/1
$ENV{'PAGSEGURO_API_EMAIL'} || undef
$ENV{'PAGSEGURO_API_EMAIL'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_EMAIL'}
Aresult
11
00
21  
22 $args{token} = $ENV{PAGSEGURO_API_TOKEN} || undef
23 12 ▶ unless $args{token};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"token"} 2 10 12
Condition100%2/2
$ENV{'PAGSEGURO_API_TOKEN'} || undef
l!l
11
MC/DC100%1/1
$ENV{'PAGSEGURO_API_TOKEN'} || undef
$ENV{'PAGSEGURO_API_TOKEN'}
Truth table100%2/2
A
A= $ENV{'PAGSEGURO_API_TOKEN'}
Aresult
11
00
24  
25 # enable sandbox
26 $ENV{PAGSEGURO_API_SANDBOX} = $args{sandbox}
27 12 ▶ if $args{sandbox};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"sandbox"} 0 12 12
28  
29 # enable debug
30 $ENV{PAGSEGURO_API_DEBUG} = $args{debug}
31 12 ▶ if $args{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"debug"} 0 12 12
32  
33 return bless {
34 _email => $args{email} || undef,
35 _token => $args{token} || undef,
36  
37 12 ▶ _checkout => undef,
Condition100%4/4
$args{'email'} || undef
l!l
111
$args{'token'} || undef
l!l
111
MC/DC100%1/1
$args{'email'} || undef
$args{'email'}
MC/DC100%1/1
$args{'token'} || undef
$args{'token'}
Truth table100%2/2
A
A= $args{'email'}
Aresult
11
00
Truth table100%2/2
A
A= $args{'token'}
Aresult
11
00
38 _transaction => undef,
39 _notification => undef,
40 }, $class;
41 }
42  
43 # accessors
44 sub email {
45 18 ▶ $_[0]->{_email} = $_[1] if $_[1];
Subroutine email: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 18 18
46 18 return shift->{_email};
47 }
48  
49 sub token {
50 18 ▶ $_[0]->{_token} = $_[1] if $_[1];
Subroutine token: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 18 18
51 18 return shift->{_token};
52 }
53  
54 # methods
55 sub transaction {
56 4 ▶ my $self = shift;
Subroutine transaction: called CC=6 SCAR=20.3
Pod documented
57  
58 # error
59 4 ▶ die "Exception: e-mail or token undef"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->email and $self->token 0 4 4
Condition33%1/3
$self->email and $self->token
!ll&&!rl&&r
004
MC/DC0%0/2
$self->email and $self->token
$self->email $self->token
Truth table33%1/3
A and B
A= $self->emailB= $self->token
ABresult
0X0
100
111
60 unless $self->email && $self->token;
61  
62 # manual instance
63 4 ▶ $self->{_transaction} = $_[0]
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] and $_[0]->isa("PagSeguro::API::Transaction") 0 4 4
Condition33%1/3
$_[0] and $_[0]->isa("PagSeguro::API::Transaction")
!ll&&!rl&&r
400
MC/DC0%0/2
$_[0] and $_[0]->isa("PagSeguro::API::Transaction")
$_[0] $_[0]->isa("PagSeguro::API::Transaction")
Truth table33%1/3
A and B
A= $_[0]B= $_[0]->isa("PagSeguro::API::Transaction")
ABresult
0X0
100
111
64 if $_[0] && $_[0]->isa('PagSeguro::API::Transaction');
65  
66  
67 $self->{_transaction} = PagSeguro::API::Transaction->new(
68 email => $self->email, token => $self->token
69 4 ▶ ) unless $self->{_transaction};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_transaction"} 2 2 4
70  
71 4 return $self->{_transaction};
72 }
73  
74 sub notification {
75 2 ▶ my $self = shift;
Subroutine notification: called CC=6 SCAR=21.4
Pod documented
76  
77 # error
78 2 ▶ die "Exception: e-mail or token undef"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->email and $self->token 0 2 2
Condition33%1/3
$self->email and $self->token
!ll&&!rl&&r
002
MC/DC0%0/2
$self->email and $self->token
$self->email $self->token
Truth table33%1/3
A and B
A= $self->emailB= $self->token
ABresult
0X0
100
111
79 unless $self->email && $self->token;
80  
81 # manual instance
82 2 ▶ $self->{_notification} = $_[0]
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] and $_[0]->isa("PagSeguro::API::Notification") 0 2 2
Condition33%1/3
$_[0] and $_[0]->isa("PagSeguro::API::Notification")
!ll&&!rl&&r
200
MC/DC0%0/2
$_[0] and $_[0]->isa("PagSeguro::API::Notification")
$_[0] $_[0]->isa("PagSeguro::API::Notification")
Truth table33%1/3
A and B
A= $_[0]B= $_[0]->isa("PagSeguro::API::Notification")
ABresult
0X0
100
111
83 if $_[0] && $_[0]->isa('PagSeguro::API::Notification');
84  
85  
86 $self->{_notification} = PagSeguro::API::Notification->new(
87 email => $self->email, token => $self->token
88 2 ▶ ) unless $self->{_notification};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_notification"} 2 0 2
89  
90 2 return $self->{_notification};
91 }
92  
93 sub checkout {
94 3 ▶ my $self = shift;
Subroutine checkout: called CC=6 SCAR=20.3
Pod documented
95  
96 # error
97 3 ▶ die "Exception: e-mail or token undef"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->email and $self->token 0 3 3
Condition33%1/3
$self->email and $self->token
!ll&&!rl&&r
003
MC/DC0%0/2
$self->email and $self->token
$self->email $self->token
Truth table33%1/3
A and B
A= $self->emailB= $self->token
ABresult
0X0
100
111
98 unless $self->email && $self->token;
99  
100 # manual instance
101 3 ▶ $self->{_checkout} = $_[0]
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] and $_[0]->isa("PagSeguro::API::Checkout") 0 3 3
Condition33%1/3
$_[0] and $_[0]->isa("PagSeguro::API::Checkout")
!ll&&!rl&&r
300
MC/DC0%0/2
$_[0] and $_[0]->isa("PagSeguro::API::Checkout")
$_[0] $_[0]->isa("PagSeguro::API::Checkout")
Truth table33%1/3
A and B
A= $_[0]B= $_[0]->isa("PagSeguro::API::Checkout")
ABresult
0X0
100
111
102 if $_[0] && $_[0]->isa('PagSeguro::API::Checkout');
103  
104  
105 $self->{_checkout} = PagSeguro::API::Checkout->new(
106 email => $self->email, token => $self->token
107 3 ▶ ) unless $self->{_checkout};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_checkout"} 2 1 3
108  
109 3 return $self->{_checkout};
110 }
111  
112  
113 6 1;
114 __END__
« lib/PagSeguro/API/Transaction.pm ↑ Summary lib/PagSeguro/API/Notification.pm »