NAME
Data::Person - Data object for person.
SYNOPSIS
use
Data::Person;
my
$obj
= Data::Person->new(
%params
);
my
=
$obj
->email;
my
$external_ids_ar
=
$obj
->external_ids;
my
$id
=
$obj
->id;
my
$name
=
$obj
->name;
my
$sex
=
$obj
->sex;
METHODS
new
my
$obj
= Data::Person->new(
%params
);
Constructor.
Returns instance of object.
email
Person's email for external identification. It's optional. Default value is undef.
external_ids
Person external ids. It's optional. Value must be a instance of Data::ExternalId object. Default value is [].
id
Id of person. It's natural number. It's optional. Default value is undef.
name
Name of person. Length of name is 255. It's optional.
sex
Sex of person. Possible values are: female, male and unknown. It's optional.
email
my
=
$obj
->email;
Get person email.
Returns string.
external_ids
my
$external_ids_ar
=
$obj
->external_ids;
Get external ids.
Returns reference to array with Data::ExternalId instances.
id
my
$id
=
$obj
->id;
Get person id.
Returns number.
name
my
$name
=
$obj
->name;
Get person name.
Returns string.
sex
my
$sex
=
$obj
->sex;
Get person sex.
Returns string.
ERRORS
new():
From Mo::utils::check_array_object():
Parameter
'external_ids'
must be a array.
Value:
%s
Reference:
%s
External id isn
't '
Data::ExternalId' object.
Value:
%s
Reference:
%s
From Mo::utils::check_number_id():
Parameter
'id'
must a natural number.
Value:
%s
Parameter
'name'
has
length
greater than
'255'
.
Value:
%s
Parameter
'sex'
must be one of
defined
strings.
String:
%s
Possible strings:
%s
EXAMPLE
use
strict;
use
warnings;
use
Data::ExternalId;
use
Data::Person;
use
DateTime;
my
$obj
= Data::Person->new(
'email'
=>
'skim@cpan.org'
,
'external_ids'
=> [
Data::ExternalId->new(
'key'
=>
'Wikidata'
,
'value'
=>
'Q27954834'
,
),
],
'id'
=> 1,
'name'
=> decode_utf8(
'Michal Josef Špaček'
),
'sex'
=>
'male'
,
);
# Print out.
'Id: '
.
$obj
->id.
"\n"
;
'Name: '
.encode_utf8(
$obj
->name).
"\n"
;
'Email: '
.
$obj
->email.
"\n"
;
'Sex: '
.
$obj
->sex.
"\n"
;
foreach
my
$external_id
(@{
$obj
->external_ids}) {
'External id - '
.
$external_id
->key.
': '
.
$external_id
->value.
"\n"
;
}
# Output:
# Id: 1
# Name: Michal Josef Špaček
# Email: skim@cpan.org
# Sex: male
# External id - Wikidata: Q27954834
DEPENDENCIES
Mo, Mo::utils, Mo::utils::Email, Readonly.
REPOSITORY
https://github.com/michal-josef-spacek/Data-Person
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2021-2025 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.04