lib/HTML/FormFu/FakeQuery.pm

filter: Statementstmt 86.0% 37 / 43 Branchbran 81.8% 18 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 5 totaltotal 77.2% 61 / 79 CC 13 SCAR 17.7
CC
13
Cov
85%
param
9.9
new
5.0
multi_param
2.0
CRAP 5.9
« lib/HTML/FormFu/Constraint/Repeatable/Any.pm ↑ Summary lib/HTML/FormFu/Localize.pm »
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
BranchTrueFalseTotal
if builtin::reftype($param) ne "HASH" 0 425 425
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
BranchTrueFalseTotal
if exists $param->{$name} 956 353 1309
24  
25 353 ▶ if ( $form->nested_hash_key_exists( $param, $name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form->nested_hash_key_exists($param, $name)) 3 350 353
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 &param }
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
BranchTrueFalseTotal
if (not @_) { } 847 2515 3362
elsif (@_ == 2) { } 0 2515 2515
elsif (@_ == 1) { } 2515 0 2515
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
BranchTrueFalseTotal
unless (exists $self->{"_params"}{$param}) 456 2059 2515
53 456 ▶ return wantarray ? () : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 456 456
54 }
55  
56 2059 ▶ if ( ref $self->{_params}{$param} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'_params'}{$param} eq 'ARRAY') { } 146 1913 2059
57 return (wantarray)
58 86 ? @{ $self->{_params}{$param} }
59 146 ▶ : $self->{_params}{$param}->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 86 60 146
60 }
61 else {
62 return (wantarray)
63 ? ( $self->{_params}{$param} )
64 1913 ▶ : $self->{_params}{$param};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 944 969 1913
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__
« lib/HTML/FormFu/Constraint/Repeatable/Any.pm ↑ Summary lib/HTML/FormFu/Localize.pm »