line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LWP::Authen::OAuth2::Args; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Args |
4
|
|
|
|
|
|
|
our $VERSION = '0.20'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
73467
|
use warnings; |
|
9
|
|
|
|
|
39
|
|
|
9
|
|
|
|
|
317
|
|
7
|
9
|
|
|
9
|
|
56
|
use strict; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
226
|
|
8
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
46
|
use Carp qw(croak confess); |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
577
|
|
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
9
|
|
61
|
use Exporter qw(import); |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
4248
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(extract_option copy_option assert_options_empty); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Blessed empty hash. |
16
|
|
|
|
|
|
|
sub new { |
17
|
7
|
|
|
7
|
0
|
36
|
return bless {}, shift; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub extract_option { |
21
|
0
|
|
|
0
|
0
|
0
|
my $obj = shift; |
22
|
0
|
|
|
|
|
0
|
my $opts = shift; |
23
|
0
|
|
|
|
|
0
|
my $name = shift; |
24
|
0
|
|
|
|
|
0
|
my $has_default = @_; |
25
|
0
|
|
|
|
|
0
|
my $default = shift; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
0
|
if (exists $opts->{$name}) { |
|
|
0
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
return delete $opts->{$name}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ($has_default) { |
31
|
0
|
|
|
|
|
0
|
return $default; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
0
|
|
|
|
|
0
|
croak("'$name' is required, cannot be missing"); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub copy_option { |
39
|
196
|
|
|
196
|
0
|
4988
|
my $obj = shift; |
40
|
196
|
|
|
|
|
314
|
my $opts = shift; |
41
|
196
|
|
|
|
|
321
|
my $name = shift; |
42
|
196
|
|
|
|
|
312
|
my $has_default = @_; |
43
|
196
|
|
|
|
|
314
|
my $default = shift; |
44
|
|
|
|
|
|
|
|
45
|
196
|
100
|
|
|
|
470
|
if (not exists $obj->{$name}) { |
|
|
100
|
|
|
|
|
|
46
|
194
|
100
|
|
|
|
426
|
if (exists $opts->{$name}) { |
|
|
100
|
|
|
|
|
|
47
|
23
|
|
|
|
|
57
|
my $value = delete $opts->{$name}; |
48
|
23
|
100
|
|
|
|
66
|
if (defined($value)) { |
|
|
50
|
|
|
|
|
|
49
|
22
|
|
|
|
|
73
|
$obj->{$name} = $value; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ($has_default) { |
52
|
0
|
|
|
|
|
0
|
$obj->{$name} = $default; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
1
|
|
|
|
|
76
|
croak("'$name' is required, cannot be undef"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
elsif ($has_default) { |
59
|
170
|
|
|
|
|
844
|
$obj->{$name} = $default; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
1
|
|
|
|
|
74
|
croak("'$name' is required, cannot be missing"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif (exists $opts->{$name}) { |
66
|
|
|
|
|
|
|
# This should not be hit, but if it was, it would be confusing |
67
|
1
|
|
|
|
|
223
|
confess("Refusing to copy '$name' that is already in hash"); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub assert_options_empty { |
72
|
2
|
|
|
2
|
0
|
1337
|
my ($obj, $opts) = @_; |
73
|
2
|
|
|
|
|
9
|
my @keys = sort keys %$opts; |
74
|
2
|
100
|
|
|
|
11
|
if (1 == @keys) { |
|
|
50
|
|
|
|
|
|
75
|
1
|
|
|
|
|
128
|
croak("Unexpected parameter: '$keys[0]'"); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif (@keys) { |
78
|
0
|
|
|
|
|
|
my $extra = "'" . (join "', '", @keys) . "'"; |
79
|
0
|
|
|
|
|
|
croak("Extra parameters: $extra"); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |