Silki/Schema/Policy.pm

filter: Statementstmt 70.3% 38 / 54 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 64.7% 11 / 17 Podpod n/a totaltotal 55.0% 49 / 89 CC 7 SCAR 15.7
CC
7
Cov
56%
__ANON__
12.0
__ANON__
12.0
__ANON__
6.0
CRAP 4.8
« Silki/Controller/File.pm ↑ Summary Silki/Controller/Process.pm »
1 package Silki::Schema::Policy;
2 {
3 1 $Silki::Schema::Policy::VERSION = '0.29';
4 }
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use DateTime::Format::Pg;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Encode qw( decode );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Lingua::EN::Inflect qw( PL_N );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Fey::ORM::Policy;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 #<<<
17 transform_all
18 7 ▶ matching { $_[0]->name() =~ /_datetime$/ }
Subroutine __ANON__: called CC=1 SCAR=0.0
19 0 ▶ => deflate {
Subroutine __ANON__: not called CC=3 SCAR=24.8
20 0 ▶ blessed $_[1] && $_[1]->isa('DateTime')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[1]) && $_[1]->isa('DateTime') ? : 0 0 0
Condition0%0/3
builtin::blessed($_[1]) and $_[1]->isa("DateTime")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_[1]) and $_[1]->isa("DateTime")
builtin::blessed($_[1]) $_[1]->isa("DateTime")
Truth table0%0/3
A and B
A= builtin::blessed($_[1])B= $_[1]->isa("DateTime")
ABresult
0X0
100
111
21 ? DateTime::Format::Pg->format_datetime( $_[1] )
22 : $_[1];
23 }
24 0 ▶ => inflate {
Subroutine __ANON__: not called CC=2 SCAR=17.9
25 0 ▶ return $_[1] unless defined $_[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 0 0 0
26 0 my $dt = DateTime::Format::Pg->parse_datetime( $_[1] );
27 0 $dt->set_time_zone('UTC');
28 0 return $dt;
29 1 };
30 #>>>
31 #<<<
32 transform_all
33 7 ▶ matching { $_[0]->name() =~ /_date$/ } =>
Subroutine __ANON__: called CC=1 SCAR=0.0
34 0 ▶ deflate {
Subroutine __ANON__: not called CC=3 SCAR=24.8
35 0 ▶ blessed $_[1] && $_[1]->isa('DateTime')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[1]) && $_[1]->isa('DateTime') ? : 0 0 0
Condition0%0/3
builtin::blessed($_[1]) and $_[1]->isa("DateTime")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_[1]) and $_[1]->isa("DateTime")
builtin::blessed($_[1]) $_[1]->isa("DateTime")
Truth table0%0/3
A and B
A= builtin::blessed($_[1])B= $_[1]->isa("DateTime")
ABresult
0X0
100
111
36 ? DateTime::Format::Pg->format_date( $_[1] )
37 : $_[1];
38 }
39 0 ▶ => inflate {
Subroutine __ANON__: not called CC=2 SCAR=17.9
40 0 ▶ return $_[1] unless defined $_[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 0 0 0
41 0 my $dt = DateTime::Format::Pg->parse_date( $_[1] );
42 0 $dt->set_time_zone('UTC');
43 0 return $dt;
44 1 };
45 #>>>
46 # This is a hack that should not be necessary, but DBD::Pg has a fixed list of
47 # column types it will treat as utf-8, and user-defined types are not
48 # included. See https://rt.cpan.org/Ticket/Display.html?id=40199 for details.
49 1 my %text_types = map { $_ => 1 } qw( citext email_address filename );
50 #<<<
51 transform_all
52 7 ▶ matching { $text_types{ lc $_[0]->type() } } =>
Subroutine __ANON__: called CC=1 SCAR=0.0
53 0 ▶ inflate {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 return decode( 'utf-8', $_[1] );
55 1 };
56 #>>>
57 1 ▶has_one_namer {
Subroutine __ANON__: called CC=1 SCAR=0.0
58 1 my $name = $_[0]->name();
59 1 my @parts = map {lc} ( $name =~ /([A-Z][a-z]+)/g );
60  
61 1 return join q{_}, @parts;
62 1 };
63  
64 0 ▶has_many_namer {
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 0 my $name = $_[0]->name();
66 0 my @parts = map {lc} ( $name =~ /([A-Z][a-z]+)/g );
67  
68 0 $parts[-1] = PL_N( $parts[-1] );
69  
70 0 return join q{_}, @parts;
71 1 };
72  
73 1 1;
74  
75 # ABSTRACT: A Fey::Policy for Silki
76  
77 __END__
« Silki/Controller/File.pm ↑ Summary Silki/Controller/Process.pm »