More/InputTie.pm

filter: Statementstmt 79.3% 23 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 58.3% 7 / 12 Podpod n/a totaltotal 73.1% 30 / 41 CC 1 SCAR 3.5
CC
1
Cov
79%
SCALAR
2.0
FIRSTKEY
2.0
NEXTKEY
2.0
CRAP 1.4
« More.pm ↑ Summary
1 package CGI::FormBuilderX::More::InputTie;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Carp::Clan qw/^CGI::FormBuilderX::More::/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 SYNOPSIS
9  
10 use CGI::FormBuilderX::More;
11 use CGI::FormBuilderX::More::InputTie;
12  
13 my $form = CGI::FormBuilderX::More->new( ... );
14 my %hash;
15 tie %hash, $form; # %hash is now tied to the input of $form
16  
17 if (exists $hash{username}) {
18 ...
19 }
20  
21 $hash{password} = "12345"
22  
23 =head1 METHODS
24  
25 =head2 TIEHASH($form)
26  
27 my %hash;
28 tie %hash, $form;
29  
30 # %hash is now tied to $form input
31
32 =cut
33  
34 3 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=1 SCAR=0.0
35 3 my $self = bless {}, shift;
36 3 my $form = shift;
37 3 $self->{form} = $form;
38 3 return $self;
39 }
40  
41 =head2 STORE($key, $value)
42  
43 $hash{$key} = $value
44  
45 sub {
46 return $form->input_store($key, $value)
47 }
48  
49 =cut
50  
51 1 ▶sub STORE {
Subroutine STORE: called CC=1 SCAR=0.0
52 1 my $self = shift;
53 1 my ($key, $value) = @_;
54 1 return $self->{form}->input_store($key => $value);
55 }
56  
57 =head2 FETCH($key)
58  
59 $value = $hash{$key};
60  
61 sub {
62 return $form->input_fetch($key)
63 }
64  
65 =cut
66  
67 2 ▶sub FETCH {
Subroutine FETCH: called CC=1 SCAR=0.0
68 2 my $self = shift;
69 2 my ($key) = @_;
70 2 return $self->{form}->input_fetch($key);
71 }
72  
73 =head2 EXISTS($key)
74  
75 exists $hash{$key};
76  
77 sub {
78 return ! $form->missing($key)
79 }
80  
81 =cut
82  
83 7 ▶sub EXISTS {
Subroutine EXISTS: called CC=1 SCAR=0.0
84 7 my $self = shift;
85 7 my ($key) = @_;
86 7 return ! $self->{form}->missing($key);
87 }
88  
89 =head2 SCALAR
90  
91 sub {
92 return scalar $form->{params}->param
93 }
94  
95 =cut
96  
97 0 ▶sub SCALAR {
Subroutine SCALAR: not called CC=1 SCAR=6.9
98 0 my $self = shift;
99 0 return scalar $self->{form}->{params}->param;
100 }
101  
102 =head2 FIRSTKEY
103  
104 N/A
105  
106 =cut
107  
108 0 ▶sub FIRSTKEY {
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
109 0 croak __PACKAGE__ . "::FIRSTKEY is invalid"
110 }
111  
112 =head2 NEXTKEY
113  
114 N/A
115  
116 =cut
117  
118 0 ▶sub NEXTKEY {
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
119 0 croak __PACKAGE__ . "::NEXTKEY is invalid"
120 }
121  
122 =head2 DELETE
123  
124 N/A
125  
126 =cut
127  
128 0 ▶sub DELETE {
Subroutine DELETE: not called CC=1 SCAR=6.9
129 0 croak __PACKAGE__ . "::DELETE is invalid"
130 }
131  
132 =head2 CLEAR
133  
134 N/A
135  
136 =cut
137  
138 0 ▶sub CLEAR {
Subroutine CLEAR: not called CC=1 SCAR=6.9
139 0 croak __PACKAGE__ . "::CLEAR is invalid"
140 }
141  
142 3 1;
« More.pm ↑ Summary