blib/lib/DBIx/Class/InflateColumn/TimePiece.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 2 / 2 Conditioncond 100% 8 / 8 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 49 / 49 CC 5 SCAR 9.8
CC
5
Cov
100%
register_column
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
↑ Summary
1 package DBIx::Class::InflateColumn::TimePiece;
2  
3 # ABSTRACT: Auto-create Time::Piece objects from integer columns
4 2 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use parent 'DBIx::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use Time::Piece;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our $VERSION = '0.02';
14  
15 sub register_column {
16 14 ▶ my ($self, $column, $info, @rest) = @_;
Subroutine register_column: called CC=5 SCAR=16.1
Pod documented
17  
18 14 $self->next::method( $column, $info, @rest );
19  
20 14 ▶ my $data_type = $info->{data_type} || '';
Condition100%2/2
$info->{'data_type'} || ''
l!l
104
MC/DC100%1/1
$info->{'data_type'} || ''
$info->{'data_type'}
Truth table100%2/2
A
A= $info->{'data_type'}
Aresult
11
00
21 14 ▶ my $is_integer = $data_type eq 'integer' || $data_type eq 'int';
Condition100%3/3
$data_type eq 'integer' || $data_type eq 'int'
l!l&&r!l&&!r
248
MC/DC100%2/2
$data_type eq 'integer' || $data_type eq 'int'
$data_type eq 'integer' $data_type eq 'int'
Truth table100%3/3
A || B
A= $data_type eq 'integer'B= $data_type eq 'int'
ABresult
1X1
011
000
22  
23 14 ▶ return if !$info->{inflate_time_piece} || !$is_integer;
Branch: 1 branch
BranchTrueFalseTotal
unless $info->{"inflate_time_piece"} and $is_integer 10 4 14
Condition100%3/3
$info->{"inflate_time_piece"} and $is_integer
!ll&&!rl&&r
644
MC/DC100%2/2
$info->{"inflate_time_piece"} and $is_integer
$info->{"inflate_time_piece"} $is_integer
Truth table100%3/3
A and B
A= $info->{"inflate_time_piece"}B= $is_integer
ABresult
0X0
100
111
24  
25 $self->inflate_column(
26 $column => {
27 inflate => sub {
28 6 ▶ my $dt = localtime shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
29 6 return $dt;
30 },
31 deflate => sub {
32 6 ▶ return shift->epoch;
Subroutine __ANON__: called CC=1 SCAR=0.0
33 },
34 }
35 4 );
36 }
37  
38 2 1;
39  
40 __END__
↑ Summary