Object/PublicationDate.pm

filter: Statementstmt 100% 63 / 63 Branchbran 100% 6 / 6 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 98.8% 88 / 89 CC 6 SCAR 8.3
CC
6
Cov
100%
BUILD
4.0
_check_conflict
3.0
BEGIN
1.0
CRAP 2.3
« Object.pm ↑ Summary Object/People.pm »
1 package MARC::Convert::Wikidata::Object::PublicationDate;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Mo qw(build is);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Mo::utils 0.15 qw(check_bool check_strings);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Mo::utils::Date 0.02 qw(check_date);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 11 Readonly::Array our @SOURCING_CIRCUMSTANCES => qw(circa near presumably disputed);
13 11 Readonly::Array our @PRECISION => qw(day month year decade century millenium);
14  
15 11 our $VERSION = 0.16;
16  
17 11 has copyright => (
18 is => 'ro',
19 );
20  
21 11 has date => (
22 is => 'ro',
23 );
24  
25 11 has earliest_date => (
26 is => 'ro',
27 );
28  
29 11 has end_time => (
30 is => 'ro',
31 );
32  
33 11 has latest_date => (
34 is => 'ro',
35 );
36  
37 11 has precision => (
38 is => 'ro',
39 );
40  
41 11 has sourcing_circumstances => (
42 is => 'ro',
43 );
44  
45 11 has start_time => (
46 is => 'ro',
47 );
48  
49 35 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=13.9
Pod undocumented
50 35 my $self = shift;
51  
52 # Conflicts.
53 35 _check_conflict($self, 'date', 'earliest_date');
54 34 _check_conflict($self, 'date', 'latest_date');
55 33 _check_conflict($self, 'date', 'start_time');
56 32 _check_conflict($self, 'date', 'end_time');
57 31 _check_conflict($self, 'earliest_date', 'start_time');
58 30 _check_conflict($self, 'earliest_date', 'end_time');
59 29 _check_conflict($self, 'latest_date', 'start_time');
60 28 _check_conflict($self, 'latest_date', 'end_time');
61 27 _check_conflict($self, 'precision', 'start_time');
62 26 _check_conflict($self, 'precision', 'end_time');
63 25 _check_conflict($self, 'precision', 'earliest_date');
64 24 _check_conflict($self, 'precision', 'latest_date');
65  
66 # Check 'copyright'.
67 23 ▶ if (! defined $self->{'copyright'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"copyright"}) 20 3 23
68 20 $self->{'copyright'} = 0;
69 }
70 23 check_bool($self, 'copyright');
71  
72 # Check 'date'.
73 22 check_date($self, 'date');
74  
75 # Check 'earliest_date'.
76 22 check_date($self, 'earliest_date');
77  
78 # Check 'end_time'.
79 22 check_date($self, 'end_time');
80  
81 # Check 'latest_date'.
82 22 check_date($self, 'latest_date');
83  
84 # Check 'precision'.
85 22 ▶ if (! defined $self->{'precision'} && defined $self->{'date'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"precision"} and defined $self->{"date"}) 9 13 22
Condition100%3/3
not defined $self->{"precision"} and defined $self->{"date"}
!ll&&!rl&&r
1129
MC/DC100%2/2
not defined $self->{"precision"} and defined $self->{"date"}
not defined $self->{"precision"} defined $self->{"date"}
Truth table100%3/3
not(A) and B
A= not defined $self->{"precision"}B= defined $self->{"date"}
ABresult
0X0
100
111
86 9 $self->{'precision'} = 'day';
87 }
88 22 check_strings($self, 'precision', \@PRECISION);
89  
90 # Check 'sourcing_circumstances'.
91 22 check_strings($self, 'sourcing_circumstances', \@SOURCING_CIRCUMSTANCES);
92  
93 # Check 'start_time'.
94 22 check_date($self, 'start_time');
95  
96 22 return;
97 }
98  
99 # TODO To Mo::utils.
100 354 ▶sub _check_conflict {
Subroutine _check_conflict: called CC=3 SCAR=11.0
101 354 my ($self, $param1, $param2) = @_;
102  
103 354 ▶ if (defined $self->{$param1} && defined $self->{$param2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{$param1} and defined $self->{$param2}) 12 342 354
Condition100%3/3
defined $self->{$param1} and defined $self->{$param2}
!ll&&!rl&&r
2628012
MC/DC100%2/2
defined $self->{$param1} and defined $self->{$param2}
defined $self->{$param1} defined $self->{$param2}
Truth table100%3/3
A and B
A= defined $self->{$param1}B= defined $self->{$param2}
ABresult
0X0
100
111
104 12 err "Parameter '$param1' is in conflict with parameter '$param2'.";
105 }
106  
107 342 return;
108 }
109  
110 11 1;
111  
112 __END__
« Object.pm ↑ Summary Object/People.pm »