Stripe/Product/PackageDimension.pm

filter: Statementstmt 37.5% 24 / 64 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.3% 8 / 15 Podpod 100% 6 / 6 totaltotal 36.8% 38 / 103 CC 11 SCAR 25.7
CC
11
Cov
29%
use_metric
30.0
_set_get_convert_size
20.0
_set_get_convert_weight
20.0
CRAP 13.0
« Stripe/Connect/Account/ExternalAccounts.pm ↑ Summary Stripe/Event/Data.pm »
1 ##----------------------------------------------------------------------------
2 ## Stripe API - ~/lib/Net/API/Stripe/Product/PackageDimension.pm
3 ## Version v0.100.1
4 ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2019/11/02
7 ## Modified 2020/05/16
8 ##
9 ##----------------------------------------------------------------------------
10 package Net::API::Stripe::Product::PackageDimension;
11 BEGIN
12 2 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶ use parent qw( Net::API::Stripe::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 our( $VERSION ) = 'v0.100.1';
18 };
19  
20 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 sub init
24 1 ▶{
Subroutine init: called CC=1 SCAR=0.0
Pod documented
25 1 my $self = shift( @_ );
26 # Default to using the imperial measurement, ie default measurement system in the U.S.
27 # User needs to activate the metric system
28 1 $self->{use_metric} = 0;
29 1 $self->SUPER::init( @_ );
30 1 return( $self );
31 }
32  
33 0 ▶sub height { return( shift->_set_get_convert_number( 'height', @_ ) ); }
Subroutine height: not called CC=1 SCAR=6.9
Pod documented
34  
35 0 ▶sub length { return( shift->_set_get_convert_weight( 'length', @_ ) ); }
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
36  
37 sub use_metric
38 0 ▶{
Subroutine use_metric: not called CC=5 SCAR=34.0
Pod documented
39 0 my $self = shift( @_ );
40 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
41 {
42 # Check provided and convert data on the fly
43 0 my $val = shift( @_ );
44 0 $self->{use_metric} = $val;
45 # Convert all data to metric, so it can be converted back after into inch and ounces when used for Stripe api calls
46 0 foreach my $k ( qw( height length width ) )
47 {
48 0 ▶ next if( !CORE::length( $self->{ $k } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::length $self->{$k} 0 0 0
49 0 my $v = $self->_set_get_convert_size( $k, $self->{ $k } );
50 0 $self->{ $k } = $v;
51 }
52 0 ▶ if( CORE::length( $self->{weight} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $self->{"weight"}) 0 0 0
53 {
54 0 my $v = $self->_set_get_convert_weight( 'weight', $self->{weight} );
55 0 $self->{weight} = $v;
56 }
57 }
58 0 return( $self->{use_metric} );
59 }
60  
61 0 ▶sub weight { return( shift->_set_get_number( 'weight', @_ ) ); }
Subroutine weight: not called CC=1 SCAR=6.9
Pod documented
62  
63 0 ▶sub width { return( shift->_set_get_convert_size( 'width', @_ ) ); }
Subroutine width: not called CC=1 SCAR=6.9
Pod documented
64  
65 sub _set_get_convert_size
66 0 ▶{
Subroutine _set_get_convert_size: not called CC=4 SCAR=30.0
67 0 my $self = shift( @_ );
68 0 my $field = shift( @_ );
69 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
70 {
71 0 my $num = shift( @_ );
72 0 ▶ return( $self->_set_get_number( $field, $num ) ) if( !$self->{use_metric} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"use_metric"} 0 0 0
73 # Helper method from Net::API::Stripe::Generic
74 # If metric option is on, convert the metric value into inch to be compliant with Stripe
75 0 my $new = $self->_convert_measure({ from => 'cm', value => "$num" });
76 0 return( $self->_set_get_number( $field, $new ) );
77 }
78 # No argument, just retrieving the value
79 else
80 {
81 0 my $val = $self->{ $field };
82 0 ▶ return( $val ) if( !$self->{use_metric} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"use_metric"} 0 0 0
83 0 my $new = $self->_convert_measure({ from => 'inch', value => "$val" });
84 0 require Module::Generic::Number;
85 0 return( Module::Generic::Number->new( $new ) );
86 }
87 }
88  
89 sub _set_get_convert_weight
90 0 ▶{
Subroutine _set_get_convert_weight: not called CC=4 SCAR=30.0
91 0 my $self = shift( @_ );
92 0 my $field = shift( @_ );
93 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
94 {
95 0 my $num = shift( @_ );
96 0 ▶ return( $self->_set_get_number( $field, $num ) ) if( !$self->{use_metric} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"use_metric"} 0 0 0
97 # Helper method from Net::API::Stripe::Generic
98 # If metric option is on, convert the metric value into inch to be compliant with Stripe
99 0 my $new = $self->_convert_measure({ from => 'gram', value => "$num" });
100 0 return( $self->_set_get_number( $field, $new ) );
101 }
102 # No argument, just retrieving the value
103 else
104 {
105 0 my $val = $self->{ $field };
106 0 ▶ return( $val ) if( !$self->{use_metric} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"use_metric"} 0 0 0
107 0 my $new = $self->_convert_measure({ from => 'gram', value => "$val" });
108 0 require Module::Generic::Number;
109 0 return( Module::Generic::Number->new( $new ) );
110 }
111 }
112  
113 2 1;
114  
115 __END__
« Stripe/Connect/Account/ExternalAccounts.pm ↑ Summary Stripe/Event/Data.pm »