FormValidator/Input.pm

filter: Statementstmt 100% 30 / 30 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 93.1% 41 / 44 CC 2 SCAR 1.7
CC
2
Cov
97%
BUILDARGS
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« FormValidator/Validator/Accepted.pm ↑ Summary FormValidator/Validator/Required.pm »
1 package Dancer2::Plugin::FormValidator::Input;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use Hash::Util qw(lock_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use Types::Standard qw(HashRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 ### Input ###
13 # Class to isolate and manipulate input HashRef.
14  
15 18 has _input => (
16 is => 'ro',
17 isa => HashRef,
18 required => 1,
19 init_arg => 'input',
20 );
21  
22 sub BUILDARGS {
23 19 ▶ my ($self, %args) = @_;
Subroutine BUILDARGS: called CC=2 SCAR=7.0
Pod undocumented
24  
25 19 ▶ if (my $input = $args{input}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $input = $args{"input"}) 19 0 19
26 19 $args{input} = $self->_clone_and_lock_input($input);
27 }
28  
29 18 return \%args;
30 }
31  
32 sub get {
33 36 ▶ return $_[0]->_input;
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
34 }
35  
36 # Create locked copy.
37 sub _clone_and_lock_input {
38 # Copy input to work with isolated HashRef.
39 19 ▶ my $input = dclone($_[1]);
Subroutine _clone_and_lock_input: called CC=1 SCAR=0.0
40  
41 # Lock input to prevent accidental modifying.
42 19 return lock_hashref($input);
43 }
44  
45 18 1;
« FormValidator/Validator/Accepted.pm ↑ Summary FormValidator/Validator/Required.pm »