Stripe/TimeZone.pm

filter: Statementstmt 45.9% 17 / 37 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 46.1% 6 / 13 Podpod 100% 2 / 2 totaltotal 37.8% 25 / 66 CC 5 SCAR 15.3
CC
5
Cov
36%
_obj_eq
12.9
new
6.0
__ANON__
2.0
CRAP 4.6
« Stripe/Event/Data.pm ↑ Summary Stripe/Price.pm »
1 ##----------------------------------------------------------------------------
2 ## Stripe API - ~/lib/Net/API/Stripe/TimeZone.pm
3 ## Version v0.100.0
4 ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
6 ## Created 2019/11/02
7 ## Modified 2020/05/15
8 ##
9 ##----------------------------------------------------------------------------
10 package Net::API::Stripe::TimeZone;
11 BEGIN
12 {
13 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶ use DateTime::TimeZone;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 use overload ('""' => 'name',
16 0 ▶ '==' => sub { _obj_eq(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 0 ▶ '!=' => sub { !_obj_eq(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 1 fallback => 1,
19 1 ▶ );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ our( $VERSION ) = 'v0.100.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 };
22  
23 sub new
24 {
25 0 ▶ my $this = shift( @_ );
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
26 0 ▶ my $class = ref( $this ) || $this;
Condition0%0/3
ref $this || $this
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table0%0/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
27 0 my $init = shift( @_ );
28 0 my $value = shift( @_ );
29 0 my $tz = DateTime::TimeZone->new( name => $value, @_ );
30 0 my $self = { tz => $tz };
31 0 return( bless( $self => $class ) );
32 }
33  
34 0 ▶sub name { return( shift->{tz}->name ); }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
35  
36 sub _obj_eq
37 {
38 ##return overload::StrVal( $_[0] ) eq overload::StrVal( $_[1] );
39 1 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 0 ▶ my $self = shift( @_ );
Subroutine _obj_eq: not called CC=4 SCAR=25.6
41 0 my $other = shift( @_ );
42 0 ▶ return( 0 ) if( !ref( $other ) || !$other->isa( 'Net::API::Stripe::TimeZone' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $other and $other->isa("Net::API::Stripe::TimeZone") 0 0 0
Condition0%0/3
ref $other and $other->isa("Net::API::Stripe::TimeZone")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $other and $other->isa("Net::API::Stripe::TimeZone")
ref $other $other->isa("Net::API::Stripe::TimeZone")
Truth table0%0/3
A and B
A= ref $otherB= $other->isa("Net::API::Stripe::TimeZone")
ABresult
0X0
100
111
43 0 my $name = $self->{tz}->name;
44 0 my $name2 = $other->{tz}->name;
45 0 ▶ return( 0 ) if( $name ne $name2 );
Branch: 1 branch
BranchTrueFalseTotal
if $name ne $name2 0 0 0
46 1 ▶ use overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 0 return( 1 );
48 }
49  
50 AUTOLOAD
51 {
52 0 ▶ my( $method ) = our $AUTOLOAD =~ /([^:]+)$/;
Subroutine AUTOLOAD: not called CC=1 SCAR=6.9
53 0 my $self = shift( @_ );
54 0 return( $self->{tz}->$method( @_ ) );
55 };
56  
57 ▶DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
58  
59 1 1;
60  
61 __END__
62  
63 =encoding utf8
64  
65 =head1 NAME
66  
67 Net::API::Stripe::TimeZone - A Time Zone Object
68  
69 =head1 SYNOPSIS
70  
71 # or one can pass just 'local' just like for DateTime::TineZone
72 my $tz = $stripe->account->settings->dashboard->timezone( 'Asia/Tokyo' );
73 print( $tz->name, "\n" );
74 # Asia/Tokyo
75 print( "Time zone is $tz\n" );
76 # produces: Time zone is Asia/Tokyo
77
78 my $tz2 = $stripe->account->settings->dashboard->timezone( 'local' );
79 print( "$tz is same as $tz2? ", $tz eq $tz2 ? 'yes' : 'no', "\n" );
80  
81 =head1 VERSION
82  
83 v0.100.0
84  
85 =head1 DESCRIPTION
86  
87 This is a wrapper around L<DateTime::TimeZone> to provide stringification. L<Net::API::Stripe::TimeZone> does not inherit from L<DateTime::TimeZone> but all method of L<DateTime::TimeZone> are accessible via the module B<AUTOLOAD>
88  
89 =head1 CONSTRUCTOR
90  
91 =over 4
92  
93 =item B<new>( hash init, timezone )
94  
95 Creates a new L<Net::API::Stripe::TimeZone> object.
96  
97 =back
98  
99 =head1 METHODS
100  
101 =over 4
102  
103 =item B<name>
104  
105 This is read only. It returns the current value of the time zone.
106  
107 =back
108  
109 For all other methods, see the manual page of L<DateTime::TimeZone>
110  
111 =head1 HISTORY
112  
113 =head2 v0.1
114  
115 Initial version
116  
117 =head1 AUTHOR
118  
119 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
120  
121 =head1 SEE ALSO
122  
123 Stripe API documentation:
124  
125 L<DateTime::TimeZone>
126  
127 =head1 COPYRIGHT & LICENSE
128  
129 Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
130  
131 You can use, copy, modify and redistribute this package and associated
132 files under the same terms as Perl itself.
133  
134 =cut
« Stripe/Event/Data.pm ↑ Summary Stripe/Price.pm »