lib/WebService/Braintree/ClientToken.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 92.3% 24 / 26 CC 2 SCAR 3.0
CC
2
Cov
95%
generate
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« lib/WebService/Braintree/Gateway.pm ↑ Summary lib/WebService/Braintree/Role/AdvancedSearch.pm »
1 # vim: sw=4 ts=4 ft=perl
2  
3 package WebService::Braintree::ClientToken;
4 22 $WebService::Braintree::ClientToken::VERSION = '1.7';
5 22 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 WebService::Braintree::ClientToken
11  
12 =head1 PURPOSE
13  
14 This class generates the client token needed by client-side SDKs, such as
15 Mobile and Javascript.
16  
17 =cut
18  
19 22 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 22 with 'WebService::Braintree::Role::Interface';
22  
23 22 ▶use constant DEFAULT_VERSION => "2";
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =head1 CLASS METHODS
26  
27 =head2 generate()
28  
29 This takes a hashref of parameters and returns the client token created by
30 Braintree. Unlike all other interfaces, this one does B<NOT> return an object.
31 Instead, just the token string is returned.
32  
33 WebService::Braintree::ClientToken->generate({
34 key1 => 'value1',
35 key2 => 'value2',
36 });
37  
38 =head3 Default values
39  
40 =over 4
41  
42 =item version
43  
44 This will default to the DEFAULT_VERSION of 2.
45  
46 =back
47  
48 =cut
49  
50 4 ▶sub generate {
Subroutine generate: called CC=2 SCAR=7.1
Pod documented
51 4 my ($class, $params) = @_;
52 4 ▶ $params->{version} //= DEFAULT_VERSION;
Condition50%1/2
$params->{"version"} //= 2
l!l
04
MC/DC0%0/1
$params->{"version"} //= 2
$params->{"version"}
Truth table50%1/2
A
A= $params->{"version"}
Aresult
11
00
53  
54 4 $class->gateway->client_token->generate($params);
55 }
56  
57 22 1;
58 __END__
« lib/WebService/Braintree/Gateway.pm ↑ Summary lib/WebService/Braintree/Role/AdvancedSearch.pm »