| 1 | package Data::Validate::WithYAML::Plugin::Phone; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Plugin to check Phone numbers (basic check) | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 6 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 61 | ▶ | sub check { | ||||||||||||||||||||||||||
|
Subroutine
check: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 61 | my ($class, $value, $config) = @_; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 61 | ▶ | croak "no value to check" unless defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 60 | ▶ | if ( $config && $config->{country} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$config and $config->{"country"}
MC/DC100%2/2
$config and $config->{"country"}
$config
$config->{"country"}
Truth table100%3/3
A and B
A= $configB= $config->{"country"}
| |||||||||||||||||||||||||||||
| 21 | 24 | my $country = $config->{country}; | |||||||||||||||||||||||||||
| 22 | 24 | my $return = 0; | |||||||||||||||||||||||||||
| 23 | 24 | my $number; | |||||||||||||||||||||||||||
| 24 | my $error; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 24 | require 'Number/Phone.pm'; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 24 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 29 | 24 | $number = Number::Phone->new( $country, $value ); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 10 | ▶ | return if !blessed $number; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 9 | ▶ | $error = 'No support for ' . $country if $number->isa('Number::Phone::StubCountry'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 9 | $return = 1; | |||||||||||||||||||||||||||
| 36 | 24 | }; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 24 | ▶ | croak $error if $error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 23 | return $return; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 36 | my $return = 0; | |||||||||||||||||||||||||||
| 44 | 36 | $value =~ s/\s//g; | |||||||||||||||||||||||||||
| 45 | 36 | ▶ | if( $value =~ m{\A (?: \+ | 00? ) [1-9]{2,6} \s*? [/-]? \s*? [0-9]{4,12} \z}x ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 26 | $return = 1; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 36 | return $return; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 6 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||