lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm

filter: Statementstmt 100% 39 / 39 Branchbran 71.4% 10 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 91.6% 55 / 60 SCAR 20.8
CC
8
Cov
92%
_require_constraint
6.0
get_error
3.0
BEGIN
1.0
CRAP 8.0
« lib/HTML/FormFu/Role/Populate.pm ↑ Summary lib/HTML/FormFu/Constraint/Length.pm »
1 403 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Role::ContainsElementsSharedWithField;
4 403 $HTML::FormFu::Role::ContainsElementsSharedWithField::VERSION = '2.06';
5 403 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 403 use HTML::FormFu::Util qw(
8 require_class
9 _merge_hashes
10 403 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 403 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub get_error {
14 7 ▶ my $self = shift;
Subroutine get_error: called CC=3 SCAR=11.0
Pod undocumented
15  
16 7 ▶ return if !$self->form->submitted;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->form->submitted 0 7 7
17  
18 7 my $c = $self->get_errors(@_);
19  
20 7 ▶ return @$c ? $c->[0] : ();
Branch: 1 branch
BranchTrueFalseTotal
@$c ? : 5 2 7
21 }
22  
23 sub _require_constraint {
24 268 ▶ my ( $self, $type, $arg ) = @_;
Subroutine _require_constraint: called CC=6 SCAR=18.0
25  
26 268 ▶ croak 'required arguments: $self, $type, \%options' if @_ != 3;
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 3 0 268 268
27  
28 268 eval { my %x = %$arg };
29 268 ▶ croak "options argument must be hash-ref" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 268 268
30  
31 268 my $abs = $type =~ s/^\+//;
32 268 my $not = 0;
33  
34 268 ▶ if ( $type =~ /^Not_(\w+)$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^Not_(\w+)$/i) 4 264 268
35 4 $type = $1;
36 4 $not = 1;
37 }
38  
39 268 my $class = $type;
40  
41 268 ▶ if ( !$abs ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($abs) 268 0 268
42 268 $class = "HTML::FormFu::Constraint::$class";
43 }
44  
45 268 $type =~ s/^\+//;
46  
47 268 require_class($class);
48  
49 268 my $constraint = $class->new(
50 { type => $type,
51 not => $not,
52 parent => $self,
53 } );
54  
55 # handle default_args
56 268 my $parent = $self->parent;
57  
58 268 ▶ if ( exists $parent->default_args->{constraints}{$type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parent->default_args->{"constraints"}{$type}) 1 267 268
59 1 $arg = _merge_hashes( $parent->default_args->{constraints}{$type}, $arg,
60 );
61 }
62  
63 268 $constraint->populate($arg);
64  
65 268 return $constraint;
66 }
67  
68 403 1;
69  
70 __END__
71  
72 =pod
73  
74 =encoding UTF-8
75  
76 =head1 NAME
77  
78 HTML::FormFu::Role::ContainsElementsSharedWithField
79  
80 =head1 VERSION
81  
82 version 2.06
83  
84 =head1 AUTHOR
85  
86 Carl Franks <cpan@fireartist.com>
87  
88 =head1 COPYRIGHT AND LICENSE
89  
90 This software is copyright (c) 2018 by Carl Franks.
91  
92 This is free software; you can redistribute it and/or modify it under
93 the same terms as the Perl 5 programming language system itself.
94  
95 =cut
« lib/HTML/FormFu/Role/Populate.pm ↑ Summary lib/HTML/FormFu/Constraint/Length.pm »