| 1 | 410 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package HTML::FormFu::FakeQuery; | ||||||||||||||||||
| 4 | # ABSTRACT: fake query | ||||||||||||||||||
| 5 | 410 | $HTML::FormFu::FakeQuery::VERSION = '2.09'; | |||||||||||||||||
| 6 | 410 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 410 | ▶ | use Scalar::Util qw( reftype ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 410 | ▶ | use Carp qw( croak ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | 425 | ▶ | sub new { | ||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||
| 12 | 425 | my ( $class, $form, $param ) = @_; | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 425 | ▶ | croak 'argument must be a hashref' | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 15 | if reftype($param) ne 'HASH'; | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | # handle pre-expanded input | ||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | 1309 | my @names = grep {defined} | |||||||||||||||||
| 20 | 425 | map { $_->nested_name } @{ $form->get_fields }; | |||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 425 | for my $name (@names) { | |||||||||||||||||
| 23 | 1309 | ▶ | next if exists $param->{$name}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | 353 | ▶ | if ( $form->nested_hash_key_exists( $param, $name ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 26 | 3 | $param->{$name} = $form->get_nested_hash_value( $param, $name ); | |||||||||||||||||
| 27 | } | ||||||||||||||||||
| 28 | } | ||||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | 425 | my $self = { _params => $param }; | |||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 425 | return bless $self, $class; | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | 0 | ▶ | sub multi_param { goto ¶m } | ||||||||||||||||
|
Subroutine
multi_param: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | 3362 | ▶ | sub param { | ||||||||||||||||
|
Subroutine
param: called CC=9 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||
| 38 | 3362 | my $self = shift; | |||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | 3362 | ▶ | if ( !@_ ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 41 | 847 | return keys %{ $self->{_params} }; | |||||||||||||||||
| 42 | } | ||||||||||||||||||
| 43 | elsif ( @_ == 2 ) { | ||||||||||||||||||
| 44 | 0 | my ( $param, $value ) = @_; | |||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 0 | $self->{$param} = $value; | |||||||||||||||||
| 47 | 0 | return $self->{_params}{$param}; | |||||||||||||||||
| 48 | } | ||||||||||||||||||
| 49 | elsif ( @_ == 1 ) { | ||||||||||||||||||
| 50 | 2515 | my ($param) = @_; | |||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 2515 | ▶ | if ( !exists $self->{_params}{$param} ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 53 | 456 | ▶ | return wantarray ? () : undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 54 | } | ||||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | 2059 | ▶ | if ( ref $self->{_params}{$param} eq 'ARRAY' ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 57 | return (wantarray) | ||||||||||||||||||
| 58 | 86 | ? @{ $self->{_params}{$param} } | |||||||||||||||||
| 59 | 146 | ▶ | : $self->{_params}{$param}->[0]; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 60 | } | ||||||||||||||||||
| 61 | else { | ||||||||||||||||||
| 62 | return (wantarray) | ||||||||||||||||||
| 63 | ? ( $self->{_params}{$param} ) | ||||||||||||||||||
| 64 | 1913 | ▶ | : $self->{_params}{$param}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 65 | } | ||||||||||||||||||
| 66 | } | ||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | 0 | croak 'require arguments [$name, [$value]]'; | |||||||||||||||||
| 69 | } | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | # dummy methods, so FakeQuery doesn't cause fatal errors | ||||||||||||||||||
| 72 | # if a form is submitted | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | 0 | ▶ | sub upload { } | ||||||||||||||||
|
Subroutine
upload: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | 0 | ▶ | sub uploadInfo { {} } | ||||||||||||||||
|
Subroutine
uploadInfo: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | 410 | 1; | |||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||