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 SCAR 26.1
CC
13
Cov
85%
param
9.9
new
5.0
multi_param
2.0
CRAP 13.6
« lib/HTML/FormFu/Element/DateTime.pm ↑ Summary lib/HTML/FormFu/Inflator/CompoundDateTime.pm »
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
BranchTrueFalseTotal
if builtin::reftype($param) ne "HASH" 0 400 400
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
BranchTrueFalseTotal
if exists $param->{$name} 918 222 1140
23  
24 222 ▶ if ( $form->nested_hash_key_exists( $param, $name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form->nested_hash_key_exists($param, $name)) 3 219 222
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 &param }
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
BranchTrueFalseTotal
if (not @_) { } 798 2147 2945
elsif (@_ == 2) { } 0 2147 2147
elsif (@_ == 1) { } 2147 0 2147
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
BranchTrueFalseTotal
unless (exists $self->{"_params"}{$param}) 169 1978 2147
52 169 ▶ return wantarray ? () : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 169 169
53 }
54  
55 1978 ▶ if ( ref $self->{_params}{$param} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'_params'}{$param} eq 'ARRAY') { } 146 1832 1978
56 return (wantarray)
57 86 ? @{ $self->{_params}{$param} }
58 146 ▶ : $self->{_params}{$param}->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 86 60 146
59 }
60 else {
61 return (wantarray)
62 ? ( $self->{_params}{$param} )
63 1832 ▶ : $self->{_params}{$param};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 906 926 1832
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
« lib/HTML/FormFu/Element/DateTime.pm ↑ Summary lib/HTML/FormFu/Inflator/CompoundDateTime.pm »