Normal.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 92.8% 13 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 92.8% 52 / 56 CC 9 SCAR 18.9
CC
9
Cov
94%
new
9.1
BEGIN
1.0
BEGIN
1.0
CRAP 6.6
« Normal/Type/Business.pm ↑ Summary Normal/Config/BusinessStop.pm »
1 package String::Normal;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 our $VERSION = '0.08';
5  
6 9 ▶use String::Normal::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶sub new {
Subroutine new: called CC=9 SCAR=22.1
Pod documented
9 9 my $package = shift;
10 9 my $self = {@_};
11  
12 9 ▶ if (!$self->{type} or $self->{type} eq 'business') {
Branch: 7 branches
BranchTrueFalseTotal
if (not $self->{'type'} or $self->{'type'} eq 'business') { } 3 6 9
elsif ($self->{'type'} eq 'address') { } 1 5 6
elsif ($self->{'type'} eq 'phone') { } 1 4 5
elsif ($self->{'type'} eq 'state') { } 1 3 4
elsif ($self->{'type'} eq 'city') { } 1 2 3
elsif ($self->{'type'} eq 'zip') { } 1 1 2
elsif ($self->{'type'} eq 'title') { } 1 0 1
Condition66%2/3
not $self->{"type"} or $self->{"type"} eq "business"
l!l&&r!l&&!r
306
MC/DC50%1/2
not $self->{"type"} or $self->{"type"} eq "business"
not $self->{"type"} $self->{"type"} eq "business"
Truth table66%2/3
not(A) or B
A= not $self->{"type"}B= $self->{"type"} eq "business"
ABresult
1X1
011
000
13 3 $self->{normalizer} = String::Normal::Type::Business->new( @_ );
14 } elsif ($self->{type} eq 'address') {
15 1 $self->{normalizer} = String::Normal::Type::Address->new( @_ );
16 } elsif ($self->{type} eq 'phone') {
17 1 $self->{normalizer} = String::Normal::Type::Phone->new( @_ );
18 } elsif ($self->{type} eq 'state') {
19 1 $self->{normalizer} = String::Normal::Type::State->new( @_ );
20 } elsif ($self->{type} eq 'city') {
21 1 $self->{normalizer} = String::Normal::Type::City->new( @_ );
22 } elsif ($self->{type} eq 'zip') {
23 1 $self->{normalizer} = String::Normal::Type::Zip->new( @_ );
24 } elsif ($self->{type} eq 'title') {
25 1 $self->{normalizer} = String::Normal::Type::Title->new( @_ );
26 } else {
27 0 die "type $self->{type} is not implemented\n";
28 }
29  
30 9 return bless $self, $package;
31 }
32  
33 # currently only handles business types
34 30 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
Pod documented
35 30 my ($self,$value,$type) = @_;
36  
37 30 $value = lc( $value ); # lowercase
38 30 $value =~ tr/ //s; # squeeze multiple spaces to one
39 30 $value =~ s/^ //; # trim leading space
40 30 $value =~ s/ $//; # trim trailing space
41  
42 # strip out control chars except tabs, lf's, cr's, r single quote, mdash and ndash
43 30 $value =~ s/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x91\x93-\x95\x98-\x9F]//g;
44  
45 30 return $self->{normalizer}->transform( $value );
46 }
47  
48 9 1;
49  
50 __END__
« Normal/Type/Business.pm ↑ Summary Normal/Config/BusinessStop.pm »