Model/FK.pm

filter: Statementstmt 21.4% 21 / 98 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 33.3% 5 / 15 Podpod 0.0% 0 / 7 totaltotal 15.7% 26 / 165 CC 22 SCAR 40.2
CC
22
Cov
15%
new
144.1
BUILD
12.0
columns
6.0
CRAP 55.6
« Model.pm ↑ Summary Model/Table.pm »
1 package DBIx::Model::FK;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Scalar::Util qw/weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Types::Standard qw/ArrayRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.0.1';
8 1 our $INLINE = {
9 _columns => {
10 is => 'ro',
11 isa => ArrayRef,
12 init_arg => 'columns',
13 required => 1,
14 },
15 table => {
16 is => 'ro',
17 required => 1,
18 weaken => 1,
19 },
20 _to_columns => {
21 is => 'ro',
22 isa => ArrayRef,
23 init_arg => 'to_columns',
24 required => 1,
25 },
26 to_table => {
27 is => 'ro',
28 required => 1,
29 weaken => 1,
30 },
31 };
32  
33 0 ▶sub BUILD {
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod undocumented
34 0 my $self = shift;
35  
36 0 my @list = @{ $self->_columns };
37 0 foreach my $i ( 0 .. $#list ) {
38 0 weaken( $self->_columns->[$i] );
39 0 $self->_columns->[$i]->bump_ref_count;
40 }
41  
42 0 @list = @{ $self->_to_columns };
43 0 foreach my $i ( 0 .. $#list ) {
44 0 weaken( $self->_to_columns->[$i] );
45 0 $self->_to_columns->[$i]->bump_target_count;
46 }
47 }
48  
49 0 ▶sub as_string {
Subroutine as_string: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my $self = shift;
51 0 my $prefix = shift;
52 my $str =
53 $prefix
54 . "FOREIGN KEY("
55 0 . join( ',', map { $_->name } $self->columns )
56 . ') REFERENCES '
57 . $self->to_table->name . '('
58 0 . join( ',', map { $_->name } $self->to_columns ) . ')';
59  
60 0 return $str;
61 }
62  
63 0 ▶sub columns {
Subroutine columns: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my $self = shift;
65 0 ▶ return @{ $self->_columns } if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
66 0 return $self->_columns;
67 }
68  
69 0 ▶sub to_columns {
Subroutine to_columns: not called CC=2 SCAR=17.9
Pod undocumented
70 0 my $self = shift;
71 0 ▶ return @{ $self->_to_columns } if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
72 0 return $self->_to_columns;
73 }
74  
75 ### DO NOT EDIT BELOW! (generated by Class::Inline v0.0.1)
76 #<<<
77 0 ▶ require Carp;require Scalar::Util;our@ATTRS_UNEX=(undef);sub new {my$class=
Subroutine new: not called CC=13 SCAR=49.7
Pod undocumented
78 0 ▶ shift;my$self={@_ ? @_ > 1 ? @_ : %{$_[0]}: ()};map {local$Carp::CarpLevel=
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 0 0 0
@_ > 1 ? : 0 0 0
79 $Carp::CarpLevel + 1;Carp::croak(
80 0 ▶ "missing attribute DBIx::Model::FK::$_ is required")unless exists$self->{$_}
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$_} 0 0 0
81 }'columns','to_columns','table','to_table';$self->{'_columns'}=delete$self->
82 0 ▶ {'columns'}if exists$self->{'columns'};$self->{'_to_columns'}=delete$self->{
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"columns"} 0 0 0
83 0 ▶ 'to_columns'}if exists$self->{'to_columns'};if (@ATTRS_UNEX){map {local
Branch: 2 branches
BranchTrueFalseTotal
if exists $self->{"to_columns"} 0 0 0
if (@DBIx::Model::FK::ATTRS_UNEX) { } 0 0 0
84 0 $Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::carp(
85 0 "DBIx::Model::FK attribute '$_' unexpected");delete$self->{$_ }}sort grep {
86 0 not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete$self->{$_
87 0 ▶ };$_}grep {not exists$INLINE->{$_ }}keys %$self}bless$self,ref$class ||
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
88 0 $class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{$_ })};
89 0 ▶ Carp::croak(qq{DBIx::Model::FK::$_ value invalid ($@)})if $@}grep {exists
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
90 0 $self->{$_ }}'_columns','_to_columns';map {Scalar::Util::weaken($self->{$_ }
91 0 ▶ )}grep {exists($self->{$_})&& defined$self->{$_ }}'table','to_table';my
Condition0%0/3
exists $self->{$_} && defined $self->{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{$_} && defined $self->{$_}
exists $self->{$_} defined $self->{$_}
Truth table0%0/3
A && B
A= exists $self->{$_}B= defined $self->{$_}
ABresult
0X0
100
111
92 0 ▶ @check=('DBIx::Model::FK');my@parents;while (@check){no strict 'refs';my$c=
Subroutine BEGIN: called CC=1 SCAR=2.6
Branch: 1 branch
BranchTrueFalseTotal
if (@check) 0 0 0
93 0 shift@check;push@parents,@{$c .'::ISA'};push@check,@{$c .'::ISA'}}map {$_->
94 0 ▶ BUILD()if exists &{$_.'::BUILD'}}reverse@parents;$self->BUILD()if exists &{
Branch: 1 branch
BranchTrueFalseTotal
if exists &{$_ . '::BUILD';} 0 0 0
95 0 ▶ 'BUILD'};$self}sub __ro {my (undef,undef,undef,$sub)=caller(1);local
Subroutine __ro: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if exists &{"BUILD";} 0 0 0
96 0 ▶ $Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::croak(
Condition0%0/2
$_[1] // "undef"
l!l
00
MC/DC0%0/1
$_[1] // "undef"
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
97 "attribute $sub is read-only (value: '" .($_[1]// 'undef')."')")}sub
98 0 ▶ _columns {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_columns'}}sub _to_columns {$_[
Subroutine _columns: not called CC=2 SCAR=17.9
Subroutine _to_columns: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if @_ > 1 0 0 0
if @_ > 1 0 0 0
99 0 ▶ 0]->__ro($_[1])if @_ > 1;$_[0]{'_to_columns'}}sub table {$_[0]->__ro($_[1])
Subroutine table: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
100 0 ▶ if @_ > 1;$_[0]{'table'}}sub to_table {$_[0]->__ro($_[1])if @_ > 1;$_[0]{
Subroutine to_table: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
101 0 'to_table'}}
102 #>>>
103 ### DO NOT EDIT ABOVE! (generated by Class::Inline v0.0.1)
104  
105 1 1;
« Model.pm ↑ Summary Model/Table.pm »