Neo4j/Types/Generic/DateTime.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 16 / 16 Conditioncond 100% 18 / 18 MC/DCmcdc 100% 11 / 11 Subroutinesub 100% 10 / 10 Podpod 83.3% 5 / 6 totaltotal 98.9% 98 / 99 CC 15 SCAR 17.5
CC
15
Cov
100%
new
9.0
tz_name
7.0
BEGIN
1.0
CRAP 5.8
↑ Summary Neo4j/Types/DateTime.pm »
1 2 ▶use v5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Neo4j::Types::Generic::DateTime;
6 # ABSTRACT: Generic representation of a Neo4j temporal instant value
7 2 $Neo4j::Types::Generic::DateTime::VERSION = '2.00';
8  
9 2 ▶use parent 'Neo4j::Types::DateTime';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 18 ▶sub new {
Subroutine new: called CC=9 SCAR=22.0
Pod undocumented
13 # uncoverable pod - see Generic.pod
14 18 my ($class, $dt, $tz) = @_;
15
16 18 ▶ if (ref $dt eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dt eq "") 5 13 18
17 5 my $days = int $dt / 86400;
18 5 ▶ $dt = {
Branch: 1 branch
BranchTrueFalseTotal
$dt < 0 ? : 1 4 5
19 days => $dt < 0 ? $days - 1 : $days, # floor
20 seconds => $dt % 86400,
21 };
22 5 ▶ if ($tz && 0x40 & ord substr $tz, 0, 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tz and 64 & ord substr($tz, 0, 1)) { } 1 4 5
Condition100%3/3
$tz and 64 & ord substr($tz, 0, 1)
!ll&&!rl&&r
221
MC/DC100%2/2
$tz and 64 & ord substr($tz, 0, 1)
$tz 64 & ord substr($tz, 0, 1)
Truth table100%3/3
A and B
A= $tzB= 64 & ord substr($tz, 0, 1)
ABresult
0X0
100
111
23 1 $dt->{tz_name} = $tz;
24 }
25 else {
26 4 $dt->{tz_offset} = $tz;
27 }
28 }
29
30 18 ▶ if (defined $dt->{seconds} && ! defined $dt->{nanoseconds}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dt->{"seconds"} and not defined $dt->{"nanoseconds"}) 8 10 18
Condition100%3/3
defined $dt->{"seconds"} and not defined $dt->{"nanoseconds"}
!ll&&!rl&&r
648
MC/DC100%2/2
defined $dt->{"seconds"} and not defined $dt->{"nanoseconds"}
defined $dt->{"seconds"} not defined $dt->{"nanoseconds"}
Truth table100%3/3
A and not(B)
A= defined $dt->{"seconds"}B= not defined $dt->{"nanoseconds"}
ABresult
0X0
100
111
31 8 $dt->{nanoseconds} = 0;
32 }
33 18 ▶ if (! defined $dt->{seconds} && defined $dt->{nanoseconds}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $dt->{"seconds"} and defined $dt->{"nanoseconds"}) 4 14 18
Condition100%3/3
not defined $dt->{"seconds"} and defined $dt->{"nanoseconds"}
!ll&&!rl&&r
1224
MC/DC100%2/2
not defined $dt->{"seconds"} and defined $dt->{"nanoseconds"}
not defined $dt->{"seconds"} defined $dt->{"nanoseconds"}
Truth table100%3/3
not(A) and B
A= not defined $dt->{"seconds"}B= defined $dt->{"nanoseconds"}
ABresult
0X0
100
111
34 4 $dt->{seconds} = 0;
35 }
36 18 return bless $dt, __PACKAGE__;
37 }
38  
39  
40 52 ▶sub days { shift->{days} }
Subroutine days: called CC=1 SCAR=0.0
Pod documented
41 54 ▶sub seconds { shift->{seconds} }
Subroutine seconds: called CC=1 SCAR=0.0
Pod documented
42 18 ▶sub nanoseconds { shift->{nanoseconds} }
Subroutine nanoseconds: called CC=1 SCAR=0.0
Pod documented
43 34 ▶sub tz_offset { shift->{tz_offset} }
Subroutine tz_offset: called CC=1 SCAR=0.0
Pod documented
44  
45  
46 22 ▶sub tz_name {
Subroutine tz_name: called CC=7 SCAR=19.5
Pod documented
47 22 my ($self) = @_;
48
49 22 ▶ if ( ! exists $self->{tz_name} && defined $self->{tz_offset} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{"tz_name"} and defined $self->{"tz_offset"}) 10 12 22
Condition100%3/3
not exists $self->{"tz_name"} and defined $self->{"tz_offset"}
!ll&&!rl&&r
4810
MC/DC100%2/2
not exists $self->{"tz_name"} and defined $self->{"tz_offset"}
not exists $self->{"tz_name"} defined $self->{"tz_offset"}
Truth table100%3/3
not(A) and B
A= not exists $self->{"tz_name"}B= defined $self->{"tz_offset"}
ABresult
0X0
100
111
50 10 ▶ if ( $self->{tz_offset} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tz_offset"} == 0) 2 8 10
51 2 return $self->{tz_name} = 'Etc/GMT';
52 }
53 8 my $hours = $self->{tz_offset} / -3600;
54 8 ▶ if ( $hours != int $hours || $hours > 12 || $hours < -14 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hours != int $hours or $hours > 12 or $hours < -14) 6 2 8
Condition100%6/6
$hours != int $hours or $hours > 12 or $hours < -14
l!l&&r!l&&!r
422
$hours != int $hours or $hours > 12
l!l&&r!l&&!r
224
MC/DC100%3/3
$hours != int $hours or $hours > 12 or $hours < -14
$hours != int $hours $hours > 12 $hours < -14
Truth table100%4/4
A or B or C
A= $hours != int $hoursB= $hours > 12C= $hours < -14
ABCresult
1XX1
01X1
0011
0000
55 6 return $self->{tz_name} = undef;
56 }
57 2 $self->{tz_name} = sprintf 'Etc/GMT%+i', $hours;
58 }
59
60 14 return $self->{tz_name};
61 }
62  
63 2 1;
↑ Summary Neo4j/Types/DateTime.pm »