Shakan/Fields.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 4 / 16 Podpod 100% 11 / 11 totaltotal 50.0% 29 / 58 CC 2 SCAR 8.0
CC
2
Cov
45%
Duplication
6.0
_input
2.0
TextField
2.0
CRAP 2.2
« Shakan/Field.pm ↑ Summary Shakan/Role/Model.pm »
1 package HTML::Shakan::Fields;
2 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 22 our @EXPORT = qw(
8 TextField
9 EmailField
10 URLField
11 UIntField
12 IntField
13  
14 PasswordField
15  
16 FileField
17 ImageField
18  
19 ChoiceField
20  
21 DateField
22  
23 Duplication
24 );
25  
26 # DateTimeField
27 # ImageField
28 # TimeField
29  
30 0 ▶sub _input {
Subroutine _input: not called CC=1 SCAR=6.9
31 0 HTML::Shakan::Field::Input->new( @_ );
32 }
33  
34 0 ▶sub TextField {
Subroutine TextField: not called CC=1 SCAR=6.9
Pod documented
35 0 _input(type => 'text', @_);
36 }
37  
38 0 ▶sub EmailField {
Subroutine EmailField: not called CC=1 SCAR=6.9
Pod documented
39 0 TextField(@_)->add_constraint('EMAIL_LOOSE');
40 }
41  
42 0 ▶sub URLField {
Subroutine URLField: not called CC=1 SCAR=6.9
Pod documented
43 0 TextField(@_)->add_constraint('HTTP_URL');
44 }
45  
46 0 ▶sub UIntField {
Subroutine UIntField: not called CC=1 SCAR=6.9
Pod documented
47 0 TextField(@_)->add_constraint('UINT');
48 }
49  
50 0 ▶sub IntField {
Subroutine IntField: not called CC=1 SCAR=6.9
Pod documented
51 0 TextField(@_)->add_constraint('INT');
52 }
53  
54 0 ▶sub PasswordField {
Subroutine PasswordField: not called CC=1 SCAR=6.9
Pod documented
55 0 _input(type => 'password', @_);
56 }
57  
58 0 ▶sub FileField {
Subroutine FileField: not called CC=1 SCAR=6.9
Pod documented
59 0 HTML::Shakan::Field::File->new(@_);
60 }
61  
62 0 ▶sub ImageField {
Subroutine ImageField: not called CC=1 SCAR=6.9
Pod documented
63 0 FileField(@_)->add_constraint(['FILE_MIME' => qr{image/.+}]);
64 }
65  
66 0 ▶sub ChoiceField {
Subroutine ChoiceField: not called CC=1 SCAR=6.9
Pod documented
67 0 HTML::Shakan::Field::Choice->new( @_ );
68 }
69  
70 0 ▶sub DateField {
Subroutine DateField: not called CC=1 SCAR=6.9
Pod documented
71 0 HTML::Shakan::Field::Date->new( @_ );
72 }
73  
74 0 ▶sub Duplication {
Subroutine Duplication: not called CC=2 SCAR=17.9
Pod documented
75 0 my ($name, $f1, $f2) = @_;
76 0 ▶ Carp::croak('missing args. Usage: Duplication(name, field1, field2)') unless @_ == 3;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
77 0 $f1->add_complex_constraint(
78 +{ $name => [ $f1->name(), $f2->name() ] } => [ 'DUPLICATION' ]
79 );
80 0 return ($f1, $f2);
81 }
82  
83 22 1;
84 __END__
« Shakan/Field.pm ↑ Summary Shakan/Role/Model.pm »