lib/Ftree/Person.pm

filter: Statementstmt 75.3% 61 / 81 Branchbran 36.3% 8 / 22 Conditioncond 17.9% 7 / 39 MC/DCmcdc 10.0% 2 / 20 Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 4 totaltotal 48.8% 86 / 176 CC 26 SCAR 35.8
CC
26
Cov
54%
get_soft_peers
90.0
get_spouses
42.0
get_peers
19.8
CRAP 35.9
« lib/Ftree/FamilyTreeData.pm ↑ Summary lib/Ftree/DataParsers/FieldValidatorParser.pm »
1 package Ftree::Person;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use version; our $VERSION = qv('2.3.41');
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 5 ▶use List::MoreUtils qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Params::Validate qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 5 ▶use Class::Std::Fast::Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 {
11 5 my %id_of : ATTR(:name<id>);
12 5 my %name_of : ATTR(:get<name> :set<name>);
13 5 my %gender_of : ATTR(:get<gender> :set<gender>); #0 for male, 1 for female
14 5 my %father_of : ATTR(:get<father> :set<father>);
15 5 my %mother_of : ATTR(:get<mother> :set<mother>);
16 5 my %children_of : ATTR(:get<children> :set<children>); #ARRAYREF of Person
17 5 my %email_of : ATTR(:get<email> :set<email>);
18 5 my %homepage_of : ATTR(:get<homepage> :set<homepage>);
19 5 my %date_of_birth_of : ATTR(:get<date_of_birth> :set<date_of_birth>);
20 5 my %date_of_death_of : ATTR(:get<date_of_death> :set<date_of_death>);
21 5 my %is_living_of : ATTR(:get<is_living> :set<is_living>); #1 for living, 0 for dead
22 5 my %place_of_birth_of : ATTR(:get<place_of_birth> :set<place_of_birth>);
23 5 my %place_of_death_of : ATTR(:get<place_of_death> :set<place_of_death>);
24 5 my %cemetery_of : ATTR(:get<cemetery> :set<cemetery>); # see Cemetery.pm
25 5 my %schools_of : ATTR(:get<schools> :set<schools>); #ARRAYREF of strings
26 5 my %jobs_of : ATTR(:get<jobs> :set<jobs>); #ARRAYREF of strings
27 5 my %work_places_of : ATTR(:get<work_places> :set<work_places>);
28 5 my %places_of_living_of : ATTR(:get<places_of_living> :set<places_of_living>);
29 5 my %general_of : ATTR(:get<general> :set<general>);
30 5 my %default_picture_of : ATTR(:get<default_picture> :set<default_picture>);
31
32 0 ▶ sub get_spouses {
Subroutine get_spouses: not called CC=6 SCAR=37.4
Pod undocumented
33 0 my ($self) = validate_pos(@_, {type => SCALARREF});
34 0 ▶ return () unless defined $self->get_children();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->get_children 0 0 0
35
36 0 ▶ my ($parent_1, $parent_2) = ($self->get_gender() == 0) ?
Branch: 1 branch
BranchTrueFalseTotal
$self->get_gender == 0 ? : 0 0 0
37 (\%father_of, \%mother_of) : (\%mother_of, \%father_of);
38
39 0 my @spouse_set;
40 0 foreach my $child (@{$self->get_children()}) {
41 0 my $child_ident = ident $child;
42 push @spouse_set, $parent_2->{$child_ident}
43 if($parent_1->{$child_ident} == $self
44 0 ▶ && defined $parent_2->{$child_ident});
Branch: 1 branch
BranchTrueFalseTotal
if $parent_1->{$child_ident} == $self and defined $parent_2->{$child_ident} 0 0 0
Condition0%0/3
$parent_1->{$child_ident} == $self and defined $parent_2->{$child_ident}
!ll&&!rl&&r
000
MC/DC0%0/2
$parent_1->{$child_ident} == $self and defined $parent_2->{$child_ident}
$parent_1->{$child_ident} == $self defined $parent_2->{$child_ident}
Truth table0%0/3
A and B
A= $parent_1->{$child_ident} == $selfB= defined $parent_2->{$child_ident}
ABresult
0X0
100
111
45 }
46 0 return uniq @spouse_set;
47 }
48
49 2 ▶ sub get_peers {
Subroutine get_peers: called CC=7 SCAR=29.9
Pod undocumented
50 2 my ( $self ) = validate_pos(@_, {type => SCALARREF});
51
52 2 ▶ if (defined $self->get_mother() && defined $self->get_mother()->get_children()) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->get_mother and defined $self->get_mother->get_children) { } 2 0 2
elsif (defined $self->get_father and defined $self->get_father->get_children) { } 0 0 0
Condition33%1/3
defined $self->get_mother and defined $self->get_mother->get_children
!ll&&!rl&&r
002
MC/DC0%0/2
defined $self->get_mother and defined $self->get_mother->get_children
defined $self->get_mother defined $self->get_mother->get_children
Truth table33%1/3
A and B
A= defined $self->get_motherB= defined $self->get_mother->get_children
ABresult
0X0
100
111
53 2 ▶ return grep { (!defined $_->get_father() && !defined $self->get_father()) ||
Condition33%2/6
!(defined $_->get_father || defined $self->get_father) || $_->get_father == $self->get_father
l!l&&r!l&&!r
020
defined $_->get_father || defined $self->get_father
l!l&&r!l&&!r
200
MC/DC0%0/3
!(defined $_->get_father || defined $self->get_father) || $_->get_father == $self->get_father
defined $_->get_father defined $self->get_father $_->get_father == $self->get_father
Truth table20%1/5
not(A || B) || C
A= defined $_->get_fatherB= defined $self->get_fatherC= $_->get_father == $self->get_father
ABCresult
00X1
1X11
0111
1X00
0100
54 ($_->get_father() == $self->get_father())}
55 2 @{$self->get_mother()->get_children()};
56 }
57 ▶ elsif (defined $self->get_father() && defined $self->get_father()->get_children()) {
Condition0%0/3
defined $self->get_father and defined $self->get_father->get_children
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->get_father and defined $self->get_father->get_children
defined $self->get_father defined $self->get_father->get_children
Truth table0%0/3
A and B
A= defined $self->get_fatherB= defined $self->get_father->get_children
ABresult
0X0
100
111
58 0 return grep { !defined $_->get_mother() }
59 0 @{$self->get_father()->get_children()};
60 }
61 else {
62 0 return ($self);
63 }
64 }
65
66 0 ▶ sub get_soft_peers {
Subroutine get_soft_peers: not called CC=9 SCAR=45.0
Pod undocumented
67 0 my ( $self, $parent_type ) = validate_pos(@_, {type => SCALARREF},
68 {type => SCALAR});
69
70 0 ▶ my ($parent_func, $other_parent_func) = ($parent_type eq 'mother') ?
Branch: 1 branch
BranchTrueFalseTotal
$parent_type eq 'mother' ? : 0 0 0
71 (\&get_mother, \&get_father) : (\&get_father, \&get_mother);
72
73 0 ▶ if ( defined $parent_func->($self) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &$parent_func($self)) { } 0 0 0
74 0 ▶ return grep {(!defined $other_parent_func->($_) && defined $other_parent_func->($self)) ||
Condition0%0/18
!defined(&$other_parent_func($_)) && defined &$other_parent_func($self) || defined &$other_parent_func($_) && !defined(&$other_parent_func($self)) || defined &$other_parent_func($_) && defined &$other_parent_func($self) && &$other_parent_func($_) != &$other_parent_func($self)
l!l&&r!l&&!r
000
not defined &$other_parent_func($_) and defined &$other_parent_func($self) or defined &$other_parent_func($_) and not defined &$other_parent_func($self)
l!l&&r!l&&!r
000
not defined &$other_parent_func($_) and defined &$other_parent_func($self)
!ll&&!rl&&r
000
defined &$other_parent_func($_) and not defined &$other_parent_func($self)
!ll&&!rl&&r
000
defined &$other_parent_func($_) and defined &$other_parent_func($self) and &$other_parent_func($_) != &$other_parent_func($self)
!ll&&!rl&&r
000
defined &$other_parent_func($_) and defined &$other_parent_func($self)
!ll&&!rl&&r
000
MC/DC0%0/7
!defined(&$other_parent_func($_)) && defined &$other_parent_func($self) || defined &$other_parent_func($_) && !defined(&$other_parent_func($self)) || defined &$other_parent_func($_) && defined &$other_parent_func($self) && &$other_parent_func($_) != &$other_parent_func($self)
not defined &$other_parent_func($_) defined &$other_parent_func($self) defined &$other_parent_func($_) not defined &$other_parent_func($self) defined &$other_parent_func($_) defined &$other_parent_func($self) &$other_parent_func($_) != &$other_parent_func($self)
Truth table0%0/19
not(A) and B or C and not(D) || E and F and G
A= not defined &$other_parent_func($_)B= defined &$other_parent_func($self)C= defined &$other_parent_func($_)D= not defined &$other_parent_func($self)E= defined &$other_parent_func($_)F= defined &$other_parent_func($self)G= &$other_parent_func($_) != &$other_parent_func($self)
ABCDEFGresult
11XXXXX1
0X11XXX1
1011XXX1
0X0X1111
0X101111
100X1111
10101111
0X0X0XX0
0X0X10X0
0X0X1100
0X100XX0
0X1010X0
0X101100
100X0XX0
100X10X0
100X1100
10100XX0
101010X0
10101100
75 (defined $other_parent_func->($_) && !defined $other_parent_func->($self)) ||
76 (defined $other_parent_func->($_) && defined $other_parent_func->($self) &&
77 $other_parent_func->($_) != $other_parent_func->($self)) }
78 0 @{$parent_func->($self)->get_children()};
79 }
80 else{
81 0 return ();
82 }
83 }
84
85 16 ▶ sub brief_info {
Subroutine brief_info: called CC=7 SCAR=19.7
Pod undocumented
86 16 my ( $self, $textGenerator ) = validate_pos(@_, {type => SCALARREF},
87 {type => HASHREF});
88
89 16 my $brief_info = "";
90 16 ▶ $brief_info .= $textGenerator->{father} . ': ' . $self->get_father()->get_name()->get_long_name() . ' '
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->get_father and defined $self->get_father->get_name 10 6 16
Condition66%2/3
defined $self->get_father and defined $self->get_father->get_name
!ll&&!rl&&r
6010
MC/DC50%1/2
defined $self->get_father and defined $self->get_father->get_name
defined $self->get_father defined $self->get_father->get_name
Truth table66%2/3
A and B
A= defined $self->get_fatherB= defined $self->get_father->get_name
ABresult
0X0
100
111
91 if(defined $self->get_father() && defined $self->get_father()->get_name());
92 16 ▶ $brief_info .= $textGenerator->{mother} . ': ' . $self->get_mother()->get_name()->get_long_name() . ' '
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->get_mother and defined $self->get_mother->get_name 10 6 16
Condition66%2/3
defined $self->get_mother and defined $self->get_mother->get_name
!ll&&!rl&&r
6010
MC/DC50%1/2
defined $self->get_mother and defined $self->get_mother->get_name
defined $self->get_mother defined $self->get_mother->get_name
Truth table66%2/3
A and B
A= defined $self->get_motherB= defined $self->get_mother->get_name
ABresult
0X0
100
111
93 if(defined $self->get_mother() && defined $self->get_mother()->get_name());
94 16 ▶ $brief_info .= $textGenerator->{date_of_birth} . ': ' .$self->get_date_of_birth()->format() . ' '
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->get_date_of_birth 2 14 16
95 if(defined $self->get_date_of_birth());
96 16 ▶ $brief_info .= $textGenerator->{date_of_death} . ': ' . $self->get_date_of_death()->format() . ' '
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->get_date_of_death 0 16 16
97 if(defined $self->get_date_of_death());
98
99 16 return $brief_info;
100 }
101 }
102
103 #Static variables for unknown male and female
104 5 our $unknown_male = Ftree::Person->new( {id => 'unknown_male'} );
105 5 our $unknown_female = Ftree::Person->new( {id => 'unknown_female'} );
106
107 5 $unknown_male->set_gender(0);
108 5 $unknown_female->set_gender(1);
109
110 5 $unknown_male->set_mother($unknown_female);
111 5 $unknown_male->set_father($unknown_male);
112 5 $unknown_female->set_mother($unknown_female);
113 5 $unknown_female->set_father($unknown_male);
114
115 5 1;
« lib/Ftree/FamilyTreeData.pm ↑ Summary lib/Ftree/DataParsers/FieldValidatorParser.pm »