Line/Data.pm

filter: Statementstmt 97.6% 42 / 43 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 96.4% 54 / 56 CC 4 SCAR 7.9
CC
4
Cov
96%
_datetime
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
↑ Summary Line.pm »
1 package Log::FreeSWITCH::Line::Data;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use Error::Pure::Always;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Mo qw(builder is required);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 15 our $VERSION = 0.08;
12  
13 15 has date => (
14 'is' => 'ro',
15 'required' => 1,
16 );
17 15 has datetime_obj => (
18 'is' => 'ro',
19 'builder' => '_datetime',
20 );
21 15 has file => (
22 'is' => 'ro',
23 'required' => 1,
24 );
25 15 has file_line => (
26 'is' => 'ro',
27 'required' => 1,
28 );
29 15 has message => (
30 'is' => 'ro',
31 );
32 15 has raw => (
33 'is' => 'rw',
34 );
35 15 has time => (
36 'is' => 'ro',
37 'required' => 1,
38 );
39 15 has type => (
40 'is' => 'ro',
41 'required' => 1,
42 );
43  
44 # Create DateTime object.
45 3 ▶sub _datetime {
Subroutine _datetime: called CC=4 SCAR=13.9
46 3 my $self = shift;
47 3 eval {
48 3 require DateTime;
49 };
50 3 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Log::FreeSWITCH::Line::Data::EVAL_ERROR) 0 3 3
51 0 err "Cannot load 'DateTime' class.",
52 'Error', $EVAL_ERROR;
53 }
54 3 my ($year, $month, $day) = split m/-/ms, $self->date;
55 3 my ($hour, $min, $sec_mili) = split m/:/ms, $self->time;
56 3 my ($sec, $mili) = split m/\./ms, $sec_mili;
57 3 ▶ if (! defined $mili) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mili) 1 2 3
58 1 $mili = 0;
59 }
60 3 my $dt = eval {
61 3 DateTime->new(
62 'year' => $year,
63 'month' => $month,
64 'day' => $day,
65 'hour' => $hour,
66 'minute' => $min,
67 'second' => $sec,
68 'nanosecond' => $mili * 1000,
69 );
70 };
71 3 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Log::FreeSWITCH::Line::Data::EVAL_ERROR) 1 2 3
72 1 err 'Cannot create DateTime object.',
73 'Error', $EVAL_ERROR;
74 }
75 2 return $dt;
76 }
77  
78 15 1;
79  
80 __END__
↑ Summary Line.pm »