lib/PersonName/Format/Name.pm

filter: Statementstmt 72.0% 49 / 68 Branchbran 31.2% 5 / 16 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 78.9% 15 / 19 Podpod 100% 7 / 7 totaltotal 65.0% 78 / 120 CC 12 SCAR 15.1
CC
12
Cov
62%
__ANON__
20.0
BEGIN
4.1
external_field_name
3.3
CRAP 4.5
« lib/PersonName/Format/NullObject.pm ↑ Summary blib/lib/PersonName/Format/ScriptNames.pl »
1 ##----------------------------------------------------------------------------
2 ## Person Name Format - ~/lib/PersonName/Format/Name.pm
3 ## Version v0.1.0
4 ## Copyright(c) 2026 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2026/07/16
7 ## Modified 2026/07/16
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package PersonName::Format::Name;
14 BEGIN
15 22 ▶{
Subroutine BEGIN: called CC=3 SCAR=14.0
16 22 ▶ use v5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 22 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 22 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 22 ▶ if( $] < 5.013 )
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.013") 0 22 22
20 {
21 22 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 0 ▶ unless( defined( &warnings::register_categories ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &warnings::register_categories) 0 0 0
23 {
24 *warnings::_mkMask = sub
25 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 my $bit = shift( @_ );
27 0 my $mask = "";
28 0 vec( $mask, $bit, 1 ) = 1;
29 0 return( $mask );
30 0 };
31  
32 *warnings::register_categories = sub
33 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=30.0
34 0 my @names = @_;
35 0 foreach my $name ( @names )
36 {
37 0 ▶ if( !defined( $warnings::Bits{ $name } ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $warnings::Bits{$name}) 0 0 0
38 {
39 0 $warnings::Offsets{ $name } = $warnings::LAST_BIT;
40 0 $warnings::Bits{ $name } = warnings::_mkMask( $warnings::LAST_BIT++ );
41 0 $warnings::DeadBits{ $name } = warnings::_mkMask( $warnings::LAST_BIT++ );
42 0 ▶ if( length( $warnings::Bits{ $name } ) > length( $warnings::Bits{all} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (length $warnings::Bits{$name} > length $warnings::Bits{"all"}) 0 0 0
43 {
44 0 $warnings::Bits{all} .= "\x55";
45 0 $warnings::DeadBits{all} .= "\xaa";
46 }
47 }
48 }
49 0 };
50 }
51 }
52 22 warnings::register_categories( 'PersonName::Format' );
53 22 ▶ use parent qw( PersonName::Format::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
54 22 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
55 22 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
56 22 our( $VERSION ) = 'v0.1.0';
57 };
58  
59 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 22 my $EXTERNAL_TO_INTERNAL =
63 {
64 title => 'title',
65 given => 'given',
66 given2 => 'given2',
67 surname => 'surname',
68 surname2 => 'surname2',
69 generation => 'generation',
70 credentials => 'credentials',
71 'given-informal' => 'given_informal',
72 given_informal => 'given_informal',
73 givenInformal => 'given_informal',
74 'surname-prefix' => 'surname_prefix',
75 surname_prefix => 'surname_prefix',
76 surnamePrefix => 'surname_prefix',
77 'surname-core' => 'surname_core',
78 surname_core => 'surname_core',
79 surnameCore => 'surname_core',
80 name_locale => 'name_locale',
81 nameLocale => 'name_locale',
82 preferred_order => 'preferred_order',
83 preferredOrder => 'preferred_order',
84 };
85  
86 22 my $INTERNAL_TO_EXTERNAL =
87 {
88 title => 'title',
89 given => 'given',
90 given2 => 'given2',
91 surname => 'surname',
92 surname2 => 'surname2',
93 generation => 'generation',
94 credentials => 'credentials',
95 given_informal => 'given-informal',
96 surname_prefix => 'surname-prefix',
97 surname_core => 'surname-core',
98 name_locale => 'nameLocale',
99 preferred_order => 'preferredOrder',
100 };
101  
102 sub init
103 52 ▶{
Subroutine init: called CC=2 SCAR=7.0
Pod documented
104 52 my $self = shift( @_ );
105 52 $self->{_init_strict_use_sub} = 1;
106 52 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 52 0 52
107 52 return( $self );
108 }
109  
110 sub external_field_name
111 1 ▶{
Subroutine external_field_name: called CC=3 SCAR=12.0
Pod documented
112 1 my $self = shift( @_ );
113 1 my $field = shift( @_ );
114 1 ▶ return if( !defined( $field ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $field 0 1 1
115 1 ▶ return( $INTERNAL_TO_EXTERNAL->{ $field } // $field );
Condition33%1/3
$INTERNAL_TO_EXTERNAL->{$field} // $field
l!l&&r!l&&!r
100
MC/DC0%0/2
$INTERNAL_TO_EXTERNAL->{$field} // $field
$INTERNAL_TO_EXTERNAL->{$field} $field
Truth table33%1/3
A // B
A= $INTERNAL_TO_EXTERNAL->{$field}B= $field
ABresult
1X1
011
000
116 }
117  
118 sub get_field_value
119 0 ▶{
Subroutine get_field_value: not called CC=1 SCAR=6.9
Pod documented
120 0 my $self = shift( @_ );
121 0 return( $self->error( ref( $self ), " does not implement get_field_value()." ) );
122 }
123  
124 sub implements_name_contract
125 133 ▶{
Subroutine implements_name_contract: called CC=2 SCAR=7.0
Pod documented
126 133 my $self = shift( @_ );
127 133 my $object = shift( @_ );
128 133 ▶ return(0) unless( Scalar::Util::blessed( $object ) );
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($object) 0 133 133
129 133 return( $self->_can( $object, [qw( get_field_value name_locale preferred_order )] ) );
130 }
131  
132 sub internal_field_name
133 831 ▶{
Subroutine internal_field_name: called CC=3 SCAR=12.0
Pod documented
134 831 my $self = shift( @_ );
135 831 my $field = shift( @_ );
136 831 ▶ return if( !defined( $field ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $field 0 831 831
137 831 ▶ return( $EXTERNAL_TO_INTERNAL->{ $field } // $field );
Condition33%1/3
$EXTERNAL_TO_INTERNAL->{$field} // $field
l!l&&r!l&&!r
83100
MC/DC0%0/2
$EXTERNAL_TO_INTERNAL->{$field} // $field
$EXTERNAL_TO_INTERNAL->{$field} $field
Truth table33%1/3
A // B
A= $EXTERNAL_TO_INTERNAL->{$field}B= $field
ABresult
1X1
011
000
138 }
139  
140 0 ▶sub name_locale { return( shift->_set_get_scalar( 'name_locale', @_ ) ); }
Subroutine name_locale: not called CC=1 SCAR=6.9
Pod documented
141  
142 1 ▶sub preferred_order { return( shift->_set_get_scalar( 'preferred_order', @_ ) ); }
Subroutine preferred_order: called CC=1 SCAR=0.0
Pod documented
143  
144 22 1;
145 # NOTE: POD
146 __END__
« lib/PersonName/Format/NullObject.pm ↑ Summary blib/lib/PersonName/Format/ScriptNames.pl »