Stripe/TypeConstraints.pm

filter: Statementstmt 87.2% 41 / 47 Branchbran 100% 2 / 2 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 72.7% 16 / 22 Podpod n/a totaltotal 84.2% 64 / 76 CC 3 SCAR 4.1
CC
3
Cov
88%
__ANON__
3.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.5
« Stripe/PaymentIntent.pm ↑ Summary Stripe/Subscription.pm »
1 package Net::Stripe::TypeConstraints;
2 2 $Net::Stripe::TypeConstraints::VERSION = '0.43';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Moose::Util::TypeConstraints qw/subtype as where message enum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Custom Moose TypeConstraints for Net::Stripe object attributes and parameters
7  
8 subtype 'StripeTokenId',
9 as 'Str',
10 2 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
11 2 /^tok_.+/
12 },
13 1 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
14 1 sprintf( "Value '%s' must be a token id string of the form tok_.+", $_ );
15 2 };
16  
17 subtype 'StripeCardId',
18 as 'Str',
19 2 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 2 /^card_.+/
21 },
22 1 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 1 sprintf( "Value '%s' must be a card id string of the form card_.+", $_ );
24 2 };
25  
26 subtype 'StripeCustomerId',
27 as 'Str',
28 2 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
29 2 /^cus_.+/
30 },
31 1 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
32 1 sprintf( "Value '%s' must be a customer id string of the form cus_.+", $_ );
33 2 };
34  
35 subtype 'StripeResourceObject',
36 as 'Object',
37 6 ▶ where {
Subroutine __ANON__: called CC=3 SCAR=11.0
38 6 ▶ ( $_->isa( 'Net::Stripe::Resource' ) || $_->isa( 'Net::Stripe::Card' ) ) && $_->can( 'form_fields' )
Branch: 1 branch
BranchTrueFalseTotal
$_->isa("Net::Stripe::Resource") || $_->isa("Net::Stripe::Card") and $_->can("form_fields") 5 1 6
Condition100%3/3
$_->isa("Net::Stripe::Resource") or $_->isa("Net::Stripe::Card")
l!l&&r!l&&!r
321
MC/DC100%2/2
$_->isa("Net::Stripe::Resource") or $_->isa("Net::Stripe::Card")
$_->isa("Net::Stripe::Resource") $_->isa("Net::Stripe::Card")
Truth table100%3/3
A or B
A= $_->isa("Net::Stripe::Resource")B= $_->isa("Net::Stripe::Card")
ABresult
1X1
011
000
39 },
40 1 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 1 sprintf( "Value '%s' must be an object that inherits from Net::Stripe::Resource with a 'form_fields' method", $_ );
42 2 };
43  
44 subtype 'StripeSourceId',
45 as 'Str',
46 2 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
47 2 /^src_.+/
48 },
49 1 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
50 1 sprintf( "Value '%s' must be a source id string of the form src_.+", $_ );
51 2 };
52  
53 # ach_credit_transfer, ach_debit, alipay, bancontact, card, card_present, eps,
54 # giropay, ideal, multibanco, klarna, p24, sepa_debit, sofort, three_d_secure,
55 # or wechat
56 2 enum 'StripeSourceType' => [qw/ ach_credit_transfer card /];
57  
58 2 enum 'StripeSourceUsage' => [qw/ reusable single_use /];
59  
60 2 enum 'StripeSourceFlow' => [qw/ redirect receiver code_verification none /];
61  
62 subtype 'EmptyStr',
63 as 'Str',
64 0 ▶ where {
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 0 $_ eq ''
66 },
67 0 ▶ message {
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 sprintf( "Value '%s' must be an empty string", $_ );
69 2 };
70  
71 subtype 'StripeProductId',
72 as 'Str',
73 2 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
74 2 /^prod_.+/
75 },
76 1 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
77 1 sprintf( "Value '%s' must be a product id string of the form prod_.+", $_ );
78 2 };
79  
80 2 enum 'StripeProductType' => [qw/ good service /];
81  
82 subtype 'StripeAPIVersion',
83 as 'Str',
84 4 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
85 4 /^\d{4}-\d{2}-\d{2}$/
86 },
87 3 ▶ message {
Subroutine __ANON__: called CC=1 SCAR=0.0
88 3 sprintf( "Value '%s' must be a Stripe API version string of the form yyyy-mm-dd",
89 $_,
90 );
91 2 };
92  
93 subtype 'StripePaymentMethodId',
94 as 'Str',
95 0 ▶ where {
Subroutine __ANON__: not called CC=1 SCAR=6.9
96 0 /^pm_.+/
97 },
98 0 ▶ message {
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 0 sprintf( "Value '%s' must be a payment method id string of the form pm_.+", $_ );
100 2 };
101  
102 subtype 'StripePaymentIntentId',
103 as 'Str',
104 0 ▶ where {
Subroutine __ANON__: not called CC=1 SCAR=6.9
105 0 /^pi_.+/
106 },
107 0 ▶ message {
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 0 sprintf( "Value '%s' must be a payment intent id string of the form pi_.+", $_ );
109 2 };
110  
111 2 enum StripePaymentMethodType => [qw/ card sepia_debit ideal /];
112  
113 2 enum StripeCaptureMethod => [qw/ automatic manual /];
114  
115 2 enum StripeConfirmationMethod => [qw/ automatic manual /];
116  
117 2 enum StripeCancellationReason => [qw/ duplicate fraudulent requested_by_customer abandoned /];
118  
119 2 enum StripeSetupFutureUsage => [qw/ on_session off_session /];
120  
121 2 1;
122  
123 __END__
« Stripe/PaymentIntent.pm ↑ Summary Stripe/Subscription.pm »