« lib/HTML/FormFu/Constraint/File/Size.pm
↑ Summary
lib/HTML/FormFu/Role/Element/SingleValueField.pm »
| 1 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Constraint::File::MIME; | ||||||||||||||||||||||||||||
| 4 | 4 | $HTML::FormFu::Constraint::File::MIME::VERSION = '2.09'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: MIME Type Constraint | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | extends 'HTML::FormFu::Constraint'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use List::Util 1.33 qw( any ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | has regex => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 15 | 4 | has types => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | sub constrain_value { | ||||||||||||||||||||||||||
|
Subroutine
constrain_value: called CC=9 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 4 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | return 1 if !defined $value || $value eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $value or $value eq ""
MC/DC50%1/2
not defined $value or $value eq ""
not defined $value
$value eq ""
Truth table66%2/3
not(A) or B
A= not defined $valueB= $value eq ""
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | return if !blessed($value) || !$value->isa('HTML::FormFu::Upload'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($value) and $value->isa("HTML::FormFu::Upload")
MC/DC50%1/2
builtin::blessed($value) and $value->isa("HTML::FormFu::Upload")
builtin::blessed($value)
$value->isa("HTML::FormFu::Upload")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("HTML::FormFu::Upload")
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | my $input = $value->headers->content_type; | |||||||||||||||||||||||||||
| 25 | 2 | my $types = $self->types; | |||||||||||||||||||||||||||
| 26 | 2 | my $regex = $self->regex; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | if ( defined $types ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | if ( ref $types ne 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $types = [$types]; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | return 1 if any { $input eq $_ } @$types; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | if ( defined $regex ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 1 | return $input =~ /$regex/x; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | return; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 4 | 1; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||||||||||