| 1 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::URL; | ||||||||||||||||||||||||||||
| 4 | 4 | $HTML::FormFu::Element::URL::VERSION = '2.09'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: HTML5 URL form field | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | extends 'HTML::FormFu::Element'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | with 'HTML::FormFu::Role::Element::Input'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use HTML::FormFu::Attribute qw( mk_output_accessors ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | has http_only => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 16 | 4 | has https_only => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | has error_message => ( | |||||||||||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||||||||||
| 20 | predicate => 'has_message', | ||||||||||||||||||||||||||||
| 21 | traits => ['Chained'], | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 4 | has _has_auto_regex_constraint => ( | |||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||
| 26 | init_arg => undef, | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | __PACKAGE__->mk_output_accessors(qw( message )); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | after BUILD => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | $self->field_type('url'); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | return; | |||||||||||||||||||||||||||
| 37 | 4 | }; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 3 | ▶ | sub pre_process { | ||||||||||||||||||||||||||
|
Subroutine
pre_process: called CC=6 SCAR=19.4
| |||||||||||||||||||||||||||||
| 40 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 3 | my $constraint; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 3 | ▶ | if ( $self->_has_auto_regex_constraint ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 2 | $constraint = $self->_has_auto_regex_constraint; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | else { | ||||||||||||||||||||||||||||
| 48 | 1 | my $scheme; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | if ( $self->http_only ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 51 | 0 | $scheme = 'http'; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | elsif ( $self->https_only ) { | ||||||||||||||||||||||||||||
| 54 | 0 | $scheme = 'https'; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||
| 57 | 1 | $scheme = 'https?'; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | $constraint = $self->constraint( | |||||||||||||||||||||||||||
| 61 | { type => 'Regex', | ||||||||||||||||||||||||||||
| 62 | common => [ 'URI', 'HTTP', { -scheme => $scheme }, ], | ||||||||||||||||||||||||||||
| 63 | } ); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | $self->_has_auto_regex_constraint($constraint); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # 'pattern' attribute | ||||||||||||||||||||||||||||
| 68 | 1 | $self->pattern("$scheme://.*"); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 3 | my $message = $self->error_message; | |||||||||||||||||||||||||||
| 73 | 3 | ▶ | if ( defined $message && length $message ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $message and length $message
MC/DC0%0/2
defined $message and length $message
defined $message
length $message
Truth table33%1/3
A and B
A= defined $messageB= length $message
| |||||||||||||||||||||||||||||
| 74 | 0 | $constraint->message($message); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 3 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 4 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||