line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::Util; |
2
|
|
|
|
|
|
|
$WebService::Braintree::Util::VERSION = '0.94'; |
3
|
20
|
|
|
20
|
|
316
|
use 5.010_001; |
|
20
|
|
|
|
|
52
|
|
4
|
20
|
|
|
20
|
|
91
|
use strictures 1; |
|
20
|
|
|
|
|
119
|
|
|
20
|
|
|
|
|
621
|
|
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
1739
|
use vars qw(@ISA @EXPORT_OK); |
|
20
|
|
|
|
|
36
|
|
|
20
|
|
|
|
|
990
|
|
7
|
20
|
|
|
20
|
|
99
|
use Exporter qw(import); |
|
20
|
|
|
|
|
34
|
|
|
20
|
|
|
|
|
1053
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
11
|
|
|
|
|
|
|
hash_to_query_string |
12
|
|
|
|
|
|
|
to_instance_array |
13
|
|
|
|
|
|
|
difference_arrays |
14
|
|
|
|
|
|
|
validate_id |
15
|
|
|
|
|
|
|
is_arrayref is_hashref |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
20
|
|
|
20
|
|
5553
|
use URI::Query; |
|
20
|
|
|
|
|
110467
|
|
|
20
|
|
|
|
|
7974
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# USED by ::TransparentRedirectGateway->build_tr_data and |
21
|
|
|
|
|
|
|
# ::TestHelper->simulate_form_post_for_tr |
22
|
|
|
|
|
|
|
sub hash_to_query_string { |
23
|
0
|
|
|
0
|
0
|
0
|
my $query = URI::Query->new(__flatten(shift)); |
24
|
0
|
|
|
|
|
0
|
return $query->stringify(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# USED only by hash_to_query_string() |
28
|
|
|
|
|
|
|
sub __flatten { |
29
|
0
|
|
|
0
|
|
0
|
my($hash, $namespace) = @_; |
30
|
0
|
|
|
|
|
0
|
my %flat_hash = (); |
31
|
0
|
|
|
|
|
0
|
while (my ($key, $value) = each(%$hash)) { |
32
|
0
|
0
|
|
|
|
0
|
if (is_hashref($value)) { |
33
|
0
|
|
|
|
|
0
|
my $sub_entries = __flatten($value, __add_namespace($key, $namespace)); |
34
|
0
|
|
|
|
|
0
|
%flat_hash = (%flat_hash, %$sub_entries); |
35
|
|
|
|
|
|
|
} else { |
36
|
0
|
|
|
|
|
0
|
$flat_hash{__add_namespace($key, $namespace)} = $value; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
return \%flat_hash; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# USED only by flatten() |
43
|
|
|
|
|
|
|
sub __add_namespace { |
44
|
0
|
|
|
0
|
|
0
|
my ($key, $namespace) = @_; |
45
|
0
|
0
|
|
|
|
0
|
return $key unless $namespace; |
46
|
0
|
|
|
|
|
0
|
return "${namespace}[${key}]"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# USED only in AdvancedSearchNodes in MultipleValuesNode->in() for validation |
50
|
|
|
|
|
|
|
sub difference_arrays { |
51
|
0
|
|
|
0
|
0
|
0
|
my ($array1, $array2) = @_; |
52
|
0
|
|
|
|
|
0
|
my @diff; |
53
|
0
|
|
|
|
|
0
|
foreach my $element (@$array1) { |
54
|
0
|
0
|
|
|
|
0
|
push(@diff, $element) unless grep { $element eq $_ } @$array2; |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
0
|
return \@diff; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub to_instance_array { |
60
|
0
|
|
|
0
|
0
|
0
|
my ($attrs, $class) = @_; |
61
|
0
|
|
|
|
|
0
|
my @result = (); |
62
|
0
|
0
|
|
|
|
0
|
if (! is_arrayref($attrs)) { |
63
|
0
|
|
|
|
|
0
|
push(@result, $class->new($attrs)); |
64
|
|
|
|
|
|
|
} else { |
65
|
0
|
|
|
|
|
0
|
for (@$attrs) { |
66
|
0
|
|
|
|
|
0
|
push(@result, $class->new($_)); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
0
|
return \@result; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub validate_id { |
73
|
0
|
|
|
0
|
0
|
0
|
my $id = shift; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
0
|
return if ! defined($id); |
76
|
0
|
0
|
|
|
|
0
|
return if $id !~ /\S/; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
return 1; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub is_hashref { |
82
|
260
|
|
|
260
|
0
|
614
|
ref(shift) eq 'HASH'; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub is_arrayref { |
86
|
0
|
|
|
0
|
0
|
|
ref(shift) eq 'ARRAY'; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
__END__ |