| 1 | 403 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package HTML::FormFu::FakeQuery; | ||||||||||||||||||
| 4 | 403 | $HTML::FormFu::FakeQuery::VERSION = '2.06'; | |||||||||||||||||
| 5 | 403 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 403 | ▶ | use Scalar::Util qw( reftype ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 403 | ▶ | use Carp qw( croak ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | sub new { | ||||||||||||||||||
| 11 | 400 | ▶ | my ( $class, $form, $param ) = @_; | ||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 400 | ▶ | croak 'argument must be a hashref' | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 14 | if reftype($param) ne 'HASH'; | ||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | # handle pre-expanded input | ||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | 1140 | my @names = grep {defined} | |||||||||||||||||
| 19 | 400 | map { $_->nested_name } @{ $form->get_fields }; | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 400 | for my $name (@names) { | |||||||||||||||||
| 22 | 1140 | ▶ | next if exists $param->{$name}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 222 | ▶ | if ( $form->nested_hash_key_exists( $param, $name ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 25 | 3 | $param->{$name} = $form->get_nested_hash_value( $param, $name ); | |||||||||||||||||
| 26 | } | ||||||||||||||||||
| 27 | } | ||||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | 400 | my $self = { _params => $param }; | |||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | 400 | return bless $self, $class; | |||||||||||||||||
| 32 | } | ||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 0 | ▶ | sub multi_param { goto ¶m } | ||||||||||||||||
|
Subroutine
multi_param: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | sub param { | ||||||||||||||||||
| 37 | 2945 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
param: called CC=9 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 2945 | ▶ | if ( !@_ ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 40 | 798 | return keys %{ $self->{_params} }; | |||||||||||||||||
| 41 | } | ||||||||||||||||||
| 42 | elsif ( @_ == 2 ) { | ||||||||||||||||||
| 43 | 0 | my ( $param, $value ) = @_; | |||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | 0 | $self->{$param} = $value; | |||||||||||||||||
| 46 | 0 | return $self->{_params}{$param}; | |||||||||||||||||
| 47 | } | ||||||||||||||||||
| 48 | elsif ( @_ == 1 ) { | ||||||||||||||||||
| 49 | 2147 | my ($param) = @_; | |||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | 2147 | ▶ | if ( !exists $self->{_params}{$param} ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 52 | 169 | ▶ | return wantarray ? () : undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 53 | } | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 1978 | ▶ | if ( ref $self->{_params}{$param} eq 'ARRAY' ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 56 | return (wantarray) | ||||||||||||||||||
| 57 | 86 | ? @{ $self->{_params}{$param} } | |||||||||||||||||
| 58 | 146 | ▶ | : $self->{_params}{$param}->[0]; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 59 | } | ||||||||||||||||||
| 60 | else { | ||||||||||||||||||
| 61 | return (wantarray) | ||||||||||||||||||
| 62 | ? ( $self->{_params}{$param} ) | ||||||||||||||||||
| 63 | 1832 | ▶ | : $self->{_params}{$param}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 64 | } | ||||||||||||||||||
| 65 | } | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 0 | croak 'require arguments [$name, [$value]]'; | |||||||||||||||||
| 68 | } | ||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | # dummy methods, so FakeQuery doesn't cause fatal errors | ||||||||||||||||||
| 71 | # if a form is submitted | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | ▶ | sub upload { } | |||||||||||||||||
|
Subroutine
upload: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | 0 | ▶ | sub uploadInfo { {} } | ||||||||||||||||
|
Subroutine
uploadInfo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | 403 | 1; | |||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||
| 80 | |||||||||||||||||||
| 81 | =pod | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | =encoding UTF-8 | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | =head1 NAME | ||||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | HTML::FormFu::FakeQuery | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | =head1 VERSION | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | version 2.06 | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | =head1 AUTHOR | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||
| 98 | |||||||||||||||||||
| 99 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 102 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||
| 103 | |||||||||||||||||||
| 104 | =cut | ||||||||||||||||||