« blib/lib/Rose/HTML/Form/Field/Option/Container.pm
↑ Summary
blib/lib/Rose/HTML/Form/Field/Date.pm »
| 1 | package Rose::HTML::Form::Field::PhoneNumber::US::Split; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Rose::HTML::Form::Field::Text; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use base qw(Rose::HTML::Form::Field::Compound | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 2 | Rose::HTML::Form::Field::PhoneNumber::US); | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | # Multiple inheritence never quite works out the way I want it to... | ||||||||||||||||||||||||||||||||
| 13 | 2 | Rose::HTML::Form::Field::PhoneNumber::US->import_methods | |||||||||||||||||||||||||||||||
| 14 | ( | ||||||||||||||||||||||||||||||||
| 15 | 'validate', | ||||||||||||||||||||||||||||||||
| 16 | 'inflate_value', | ||||||||||||||||||||||||||||||||
| 17 | 'deflate_value', | ||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 2 | Rose::HTML::Form::Field::Compound->import_methods | |||||||||||||||||||||||||||||||
| 21 | ( | ||||||||||||||||||||||||||||||||
| 22 | 'name', | ||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 2 | our $VERSION = '0.606'; | |||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | sub build_field | ||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
build_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 29 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 1 | $self->add_fields | |||||||||||||||||||||||||||||||
| 32 | ( | ||||||||||||||||||||||||||||||||
| 33 | area_code => { type => 'text', size => 3, maxlength => 3, class => 'area-code' }, | ||||||||||||||||||||||||||||||||
| 34 | exchange => { type => 'text', size => 3, maxlength => 3, class => 'exchange' }, | ||||||||||||||||||||||||||||||||
| 35 | number => { type => 'text', size => 4, maxlength => 4, class => 'number' }, | ||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | sub decompose_value | ||||||||||||||||||||||||||||||||
| 40 | 17 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
decompose_value: called CC=6 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 41 | 17 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 17 | ▶ | return undef unless(defined $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 5 | my $phone = $self->inflate_value($value); | |||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 5 | ▶ | unless($phone) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||
| 49 | 0 | $phone =~ s/[- ]+//g; | |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | no warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 52 | return | ||||||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | area_code => substr($phone, 0, 3) || '', | ||||||||||||||||||||||||||||||
|
Condition0%0/6
substr($phone, 0, 3) || ''
substr($phone, 3, 6) || ''
substr($phone, 6, 4) || ''
MC/DC0%0/1
substr($phone, 0, 3) || ''
substr($phone, 0, 3)
MC/DC0%0/1
substr($phone, 3, 6) || ''
substr($phone, 3, 6)
MC/DC0%0/1
substr($phone, 6, 4) || ''
substr($phone, 6, 4)
Truth table0%0/2
A
A= substr($phone, 0, 3)
Truth table0%0/2
A
A= substr($phone, 3, 6)
Truth table0%0/2
A
A= substr($phone, 6, 4)
| |||||||||||||||||||||||||||||||||
| 55 | exchange => substr($phone, 3, 6) || '', | ||||||||||||||||||||||||||||||||
| 56 | number => substr($phone, 6, 4) || '', | ||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 5 | $phone =~ /^(\d{3})-(\d{3})-(\d{4})$/; | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | return | ||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||
| 65 | 5 | area_code => $1, | |||||||||||||||||||||||||||||||
| 66 | exchange => $2, | ||||||||||||||||||||||||||||||||
| 67 | number => $3, | ||||||||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | sub coalesce_value | ||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
coalesce_value: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 73 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | return join('-', map { defined($_) ? $_ : '' } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | 1 | map { $self->field($_)->internal_value } qw(area_code exchange number)); | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | sub html_field | ||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 80 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 2 | return '<span class="phone">' . | |||||||||||||||||||||||||||||||
| 83 | $self->field('area_code')->html_field . '-' . | ||||||||||||||||||||||||||||||||
| 84 | $self->field('exchange')->html_field . '-' . | ||||||||||||||||||||||||||||||||
| 85 | $self->field('number')->html_field . | ||||||||||||||||||||||||||||||||
| 86 | '</span>'; | ||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | sub xhtml_field | ||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 91 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 1 | return '<span class="phone">' . | |||||||||||||||||||||||||||||||
| 94 | $self->field('area_code')->xhtml_field . '-' . | ||||||||||||||||||||||||||||||||
| 95 | $self->field('exchange')->xhtml_field . '-' . | ||||||||||||||||||||||||||||||||
| 96 | $self->field('number')->xhtml_field . | ||||||||||||||||||||||||||||||||
| 97 | '</span>'; | ||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 2 | 1; | |||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||||||||||||||