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