| 1 | # Copyrights 2003-2022 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution Math-Polygon. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | package User::Identity; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use base 'User::Identity::Item'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use overload '""' => 'fullName'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | #----------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | my @attributes = qw/charset courtesy birth full_name formal_name | |||||||||||||||||||||||||||||||||||||||||
| 27 | firstname gender initials language nickname prefix surname titles /; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 7 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | exists $args->{$_} && ($self->{'UI_'.$_} = delete $args->{$_}) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | foreach @attributes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub type() { 'user' } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | sub user() { shift } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | sub charset() { shift->{UI_charset} || $ENV{LC_CTYPE} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
charset: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub nickname() | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nickname: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | ▶ | $self->{UI_nickname} || $self->name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | # TBI: If OS-specific info exists, then username | ||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | sub firstname() | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 9 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstname: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | ▶ | $self->{UI_firstname} || ucfirst $self->nickname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | sub initials() | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initials: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | return $self->{UI_initials} | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | ▶ | if defined $self->{UI_initials}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | if(my $firstname = $self->firstname) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | { my $i = ''; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | while( $firstname =~ m/(\w+)(\-)?/g ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 12 | { my ($part, $connect) = ($1,$2); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 12 | ▶ | $connect ||= '.'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$connect ||= "."
MC/DC100%1/1
$connect ||= "."
$connect
Truth table100%2/2
A
A= $connect
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | $part =~ m/^(chr|th|\w)/i; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | $i .= ucfirst(lc $1).$connect; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | return $i; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub prefix() { shift->{UI_prefix} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub surname() { shift->{UI_surname} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
surname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | sub fullName() | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 10 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fullName: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | return $self->{UI_full_name} | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 10 | ▶ | if defined $self->{UI_full_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | my ($first, $prefix, $surname) | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 10 | = @$self{ qw/UI_firstname UI_prefix UI_surname/}; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 10 | ▶ | $surname = ucfirst $self->nickname if defined $first && ! defined $surname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $first and not defined $surname
MC/DC0%0/2
defined $first and not defined $surname
defined $first
not defined $surname
Truth table66%2/3
A and not(B)
A= defined $firstB= not defined $surname
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 10 | ▶ | $first = $self->firstname if !defined $first && defined $surname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $first and defined $surname
MC/DC0%0/2
not defined $first and defined $surname
not defined $first
defined $surname
Truth table66%2/3
not(A) and B
A= not defined $firstB= defined $surname
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 10 | my $full = join ' ', grep {defined $_} ($first,$prefix,$surname); | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | ▶ | $full = $self->firstname unless length $full; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | # TBI: if OS-specific knowledge, then unix GCOS? | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | $full; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | sub formalName() | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formalName: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | return $self->{UI_formal_name} | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | if defined $self->{UI_formal_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my $initials = $self->initials; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | my $firstname = $self->{UI_firstname}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | ▶ | $firstname = "($firstname)" if defined $firstname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 15 | my $full = join ' ', grep {defined $_} | |||||||||||||||||||||||||||||||||||||||||
| 116 | $self->courtesy, $initials | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | , @$self{ qw/UI_prefix UI_surname UI_titles/ }; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | my %male_courtesy | |||||||||||||||||||||||||||||||||||||||||
| 122 | = ( mister => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 123 | , mr => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 124 | , sir => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 125 | , 'de heer' => 'nl' | ||||||||||||||||||||||||||||||||||||||||||
| 126 | , mijnheer => 'nl' | ||||||||||||||||||||||||||||||||||||||||||
| 127 | , dhr => 'nl' | ||||||||||||||||||||||||||||||||||||||||||
| 128 | , herr => 'de' | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | my %male_courtesy_default | |||||||||||||||||||||||||||||||||||||||||
| 132 | = ( en => 'Mr.' | ||||||||||||||||||||||||||||||||||||||||||
| 133 | , nl => 'De heer' | ||||||||||||||||||||||||||||||||||||||||||
| 134 | , de => 'Herr' | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | my %female_courtesy | |||||||||||||||||||||||||||||||||||||||||
| 138 | = ( miss => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 139 | , ms => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 140 | , mrs => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 141 | , madam => 'en' | ||||||||||||||||||||||||||||||||||||||||||
| 142 | , mevr => 'nl' | ||||||||||||||||||||||||||||||||||||||||||
| 143 | , mevrouw => 'nl' | ||||||||||||||||||||||||||||||||||||||||||
| 144 | , frau => 'de' | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | my %female_courtesy_default | |||||||||||||||||||||||||||||||||||||||||
| 148 | = ( en => 'Madam' | ||||||||||||||||||||||||||||||||||||||||||
| 149 | , nl => 'Mevrouw' | ||||||||||||||||||||||||||||||||||||||||||
| 150 | , de => 'Frau' | ||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | sub courtesy() | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
courtesy: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | return $self->{UI_courtesy} | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | ▶ | if defined $self->{UI_courtesy}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | ▶ | my $table | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | = $self->isMale ? \%male_courtesy_default | ||||||||||||||||||||||||||||||||||||||||||
| 161 | : $self->isFemale ? \%female_courtesy_default | ||||||||||||||||||||||||||||||||||||||||||
| 162 | : return undef; | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my $lang = lc $self->language; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | ▶ | return $table->{$lang} if exists $table->{$lang}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | $lang =~ s/\..*//; # "en_GB.utf8" --> "en-GB" and retry | |||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | return $table->{$lang} if exists $table->{$lang}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | $lang =~ s/[-_].*//; # "en_GB.utf8" --> "en" and retry | |||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | $table->{$lang}; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # TBI: if we have a courtesy, we may detect the language. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # TBI: when we have a postal address, we may derive the language from | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # the country. | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # TBI: if we have an e-mail addres, we may derive the language from | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # that. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | sub language() { shift->{UI_language} || 'en' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
language: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | ▶ | sub gender() { shift->{UI_gender} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gender: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | sub isMale() | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 6 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isMale: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | ▶ | if(my $gender = $self->{UI_gender}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | { return $gender =~ m/^[mh]/i; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | if(my $courtesy = $self->{UI_courtesy}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | { $courtesy = lc $courtesy; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $courtesy =~ s/[^\s\w]//g; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | return 1 if exists $male_courtesy{$courtesy}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | sub isFemale() | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 4 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isFemale: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | ▶ | if(my $gender = $self->{UI_gender}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | { return $gender =~ m/^[vf]/i; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | if(my $courtesy = $self->{UI_courtesy}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | { $courtesy = lc $courtesy; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $courtesy =~ s/[^\s\w]//g; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return 1 if exists $female_courtesy{$courtesy}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | ▶ | sub dateOfBirth() { shift->{UI_birth} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dateOfBirth: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | sub birth() | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | { my $birth = shift->dateOfBirth; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
birth: called CC=6 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | my $time; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | ▶ | if($birth =~ m/^\s*(\d{4})[-\s]*(\d{2})[-\s]*(\d{2})\s*$/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | { # Pre-formatted. | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | return sprintf "%04d%02d%02d", $1, $2, $3; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | eval "require Date::Parse"; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | unless($@) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | { my ($day,$month,$year) = (Date::Parse::strptime($birth))[3,4,5]; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | if(defined $year) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | { return sprintf "%04d%02d%02d" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$day || 0
MC/DC0%0/1
$day || 0
$day
Truth table50%1/2
A
A= $day
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | , ($year + 1900) | ||||||||||||||||||||||||||||||||||||||||||
| 239 | , (defined $month ? $month+1 : 0) | ||||||||||||||||||||||||||||||||||||||||||
| 240 | , ($day || 0); | ||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | # TBI: Other date parsers | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | sub age() | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | { my $birth = shift->birth or return; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
age: called CC=5 SCAR=18.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | my ($year, $month, $day) = $birth =~ m/^(\d{4})(\d\d)(\d\d)$/; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my ($today, $tomonth, $toyear) = (localtime)[3,4,5]; | |||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | $tomonth++; | |||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | my $age = $toyear+1900 - $year; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | $age-- if $month > $tomonth || ($month == $tomonth && $day >= $today); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$month > $tomonth or $month == $tomonth and $day >= $today
$month == $tomonth and $day >= $today
MC/DC0%0/3
$month > $tomonth or $month == $tomonth and $day >= $today
$month > $tomonth
$month == $tomonth
$day >= $today
Truth table0%0/4
A or B and C
A= $month > $tomonthB= $month == $tomonthC= $day >= $today
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | $age; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub titles() { shift->{UI_titles} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
titles: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||