Model/Table.pm

filter: Statementstmt 16.7% 24 / 143 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 22.2% 6 / 27 Podpod 0.0% 0 / 15 totaltotal 10.9% 30 / 273 CC 36 SCAR 33.7
CC
36
Cov
11%
new
103.5
ref_count
30.0
target_count
30.0
CRAP 29.2
« Model/FK.pm ↑ Summary Model/Column.pm »
1 package DBIx::Model::Table;
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 DBIx::Model::Column;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use DBIx::Model::FK;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Types::Standard qw/ArrayRef Int/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.0.1';
9 our $INLINE = {
10 _columns => {
11 is => 'ro',
12 isa => ArrayRef,
13 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 },
15 db => {
16 is => 'ro',
17 required => 1,
18 weaken => 1,
19 },
20 name => {
21 is => 'ro',
22 required => 1,
23 },
24 name_lc => {
25 is => 'ro',
26 init_arg => undef,
27 0 ▶ default => sub { lc $_[0]->name },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 },
29 type => {
30 is => 'ro',
31 required => 1,
32 },
33 ref_count => {
34 is => 'rw',
35 isa => Int,
36 default => 0,
37 },
38 target_count => {
39 is => 'rw',
40 isa => Int,
41 default => 0,
42 },
43 _foreign_keys => {
44 is => 'ro',
45 isa => ArrayRef,
46 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 },
48 1 };
49  
50 0 ▶sub add_column {
Subroutine add_column: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my $self = shift;
52 0 my $col = DBIx::Model::Column->new( @_, table => $self );
53 0 push( @{ $self->_columns }, $col );
54 0 return $col;
55 }
56  
57 0 ▶sub add_foreign_key {
Subroutine add_foreign_key: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my $self = shift;
59 0 my $fk = DBIx::Model::FK->new( @_, table => $self );
60 0 push( @{ $self->_foreign_keys }, $fk );
61 0 return $fk;
62 }
63  
64 0 ▶sub as_string {
Subroutine as_string: not called CC=4 SCAR=30.0
Pod undocumented
65 0 my $self = shift;
66 0 my $prefix = shift;
67 0 my $str = $prefix . $self->name;
68  
69 0 foreach my $col ( $self->columns ) {
70 0 $str .= "\n" . $col->as_string( $prefix . ' ' );
71 }
72  
73 0 ▶ if ( my @pri = $self->primaries ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@pri) = $self->primaries) 0 0 0
74 $str .=
75 0 "\n${prefix} PRIMARY(" . join( ',', map { $_->name } @pri ) . ')';
76 }
77  
78 0 foreach my $fk ( $self->foreign_keys ) {
79 0 $str .= "\n" . $fk->as_string( $prefix . ' ' );
80 }
81  
82 0 return $str;
83 }
84  
85 0 ▶sub bump_ref_count {
Subroutine bump_ref_count: not called CC=1 SCAR=6.9
Pod undocumented
86 0 my $self = shift;
87 0 $self->ref_count( $self->ref_count + 1 );
88 }
89  
90 0 ▶sub bump_target_count {
Subroutine bump_target_count: not called CC=1 SCAR=6.9
Pod undocumented
91 0 my $self = shift;
92 0 $self->target_count( $self->target_count + 1 );
93 }
94  
95 0 ▶sub columns {
Subroutine columns: not called CC=2 SCAR=17.9
Pod undocumented
96 0 my $self = shift;
97 0 ▶ return @{ $self->_columns } if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
98 0 return $self->_columns;
99 }
100  
101 0 ▶sub primaries {
Subroutine primaries: not called CC=1 SCAR=6.9
Pod undocumented
102 0 my $self = shift;
103 0 return grep { $_->primary } $self->columns;
104 }
105  
106 0 ▶sub foreign_keys {
Subroutine foreign_keys: not called CC=2 SCAR=17.9
Pod undocumented
107 0 my $self = shift;
108 0 ▶ return @{ $self->_foreign_keys } if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
109 0 return $self->_foreign_keys;
110 }
111  
112 ### DO NOT EDIT BELOW! (generated by Class::Inline v0.0.1)
113 #<<<
114 0 ▶ require Carp;require Scalar::Util;our@ATTRS_UNEX=(undef);sub new {my$class=
Subroutine new: not called CC=11 SCAR=46.4
Pod undocumented
115 0 ▶ shift;my$self={@_ ? @_ > 1 ? @_ : %{$_[0]}: ()};map {local$Carp::CarpLevel=
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 0 0 0
@_ > 1 ? : 0 0 0
116 $Carp::CarpLevel + 1;Carp::croak(
117 "missing attribute DBIx::Model::Table::$_ is required")unless exists$self->{
118 0 ▶ $_}}'db','name','type';map {delete$self->{$_}}'name_lc';if (@ATTRS_UNEX){map
Branch: 2 branches
BranchTrueFalseTotal
unless exists $self->{$_} 0 0 0
if (@DBIx::Model::Table::ATTRS_UNEX) { } 0 0 0
119 0 {local$Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::carp(
120 0 "DBIx::Model::Table attribute '$_' unexpected");delete$self->{$_ }}sort grep
121 0 {not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete$self->{
122 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
123 0 $class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{$_ })};
124 0 ▶ Carp::croak(qq{DBIx::Model::Table::$_ value invalid ($@)})if $@}grep {exists
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
125 0 $self->{$_ }}'_columns','_foreign_keys','ref_count','target_count';map {
126 0 Scalar::Util::weaken($self->{$_ })}grep {exists($self->{$_})&& defined$self
127 0 ▶ ->{$_ }}'db';my@check=('DBIx::Model::Table');my@parents;while (@check){no
Branch: 1 branch
BranchTrueFalseTotal
if (@check) 0 0 0
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
128 0 ▶ strict 'refs';my$c=shift@check;push@parents,@{$c .'::ISA'};push@check,@{$c .
Subroutine BEGIN: called CC=1 SCAR=2.2
129 0 ▶ '::ISA'}}map {$_->BUILD()if exists &{$_.'::BUILD'}}reverse@parents;$self->
Branch: 1 branch
BranchTrueFalseTotal
if exists &{$_ . '::BUILD';} 0 0 0
130 0 ▶ BUILD()if exists &{'BUILD'};$self}sub __ro {my (undef,undef,undef,$sub)=
Subroutine __ro: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if exists &{"BUILD";} 0 0 0
131 0 ▶ caller(1);local$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
132 "attribute $sub is read-only (value: '" .($_[1]// 'undef')."')")}sub
133 0 ▶ _columns {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_columns'}//= eval {$INLINE->{
Subroutine _columns: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
Condition0%0/3
$_[0]{"_columns"} //= eval { do { $DBIx::Model::Table::INLINE->{"_columns"}{"isa"}->($DBIx::Model::Table::INLINE->{"_columns"}{"default"}->($_[0])) } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"_columns"} //= eval { do { $DBIx::Model::Table::INLINE->{"_columns"}{"isa"}->($DBIx::Model::Table::INLINE->{"_columns"}{"default"}->($_[0])) } }
$_[0]{"_columns"} eval { do { $DBIx::Model::Table::INLINE->{"_columns"}{"isa"}->($DBIx::Model::Table::INLINE->{"_columns"}{"default"}->($_[0])) } }
Truth table0%0/3
A //= B
A= $_[0]{"_columns"}B= eval { do { $DBIx::Model::Table::INLINE->{"_columns"}{"isa"}->($DBIx::Model::Table::INLINE->{"_columns"}{"default"}->($_[0])) } }
ABresult
1X1
011
000
134 0 '_columns'}->{'isa'}->($INLINE->{'_columns'}->{'default'}->($_[0]))};
135 0 ▶ Carp::croak('invalid (DBIx::Model::Table::_columns) default value: ' .$@)if
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
136 0 ▶ $@;$_[0]{'_columns'}}sub _foreign_keys {$_[0]->__ro($_[1])if @_ > 1;$_[0]{
Subroutine _foreign_keys: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
137 0 ▶ '_foreign_keys'}//= eval {$INLINE->{'_foreign_keys'}->{'isa'}->($INLINE->{
Condition0%0/3
$_[0]{"_foreign_keys"} //= eval { do { $DBIx::Model::Table::INLINE->{"_foreign_keys"}{"isa"}->($DBIx::Model::Table::INLINE->{"_foreign_keys"}{"default"}->($_[0])) } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"_foreign_keys"} //= eval { do { $DBIx::Model::Table::INLINE->{"_foreign_keys"}{"isa"}->($DBIx::Model::Table::INLINE->{"_foreign_keys"}{"default"}->($_[0])) } }
$_[0]{"_foreign_keys"} eval { do { $DBIx::Model::Table::INLINE->{"_foreign_keys"}{"isa"}->($DBIx::Model::Table::INLINE->{"_foreign_keys"}{"default"}->($_[0])) } }
Truth table0%0/3
A //= B
A= $_[0]{"_foreign_keys"}B= eval { do { $DBIx::Model::Table::INLINE->{"_foreign_keys"}{"isa"}->($DBIx::Model::Table::INLINE->{"_foreign_keys"}{"default"}->($_[0])) } }
ABresult
1X1
011
000
138 0 ▶ '_foreign_keys'}->{'default'}->($_[0]))};Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
139 'invalid (DBIx::Model::Table::_foreign_keys) default value: ' .$@)if $@;$_[0
140 0 ▶ ]{'_foreign_keys'}}sub db {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'db'}}sub name
Subroutine db: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
141 0 ▶ {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'name'}}sub name_lc {$_[0]->__ro($_[1])if
Subroutine name: not called CC=2 SCAR=17.9
Subroutine name_lc: not called CC=3 SCAR=24.8
Pod undocumented
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
if @_ > 1 0 0 0
if @_ > 1 0 0 0
142 0 ▶ @_ > 1;$_[0]{'name_lc'}//= $INLINE->{'name_lc'}->{'default'}->($_[0])}sub
Condition0%0/3
$_[0]{"name_lc"} //= $DBIx::Model::Table::INLINE->{"name_lc"}{"default"}->($_[0])
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"name_lc"} //= $DBIx::Model::Table::INLINE->{"name_lc"}{"default"}->($_[0])
$_[0]{"name_lc"} $DBIx::Model::Table::INLINE->{"name_lc"}{"default"}->($_[0])
Truth table0%0/3
A //= B
A= $_[0]{"name_lc"}B= $DBIx::Model::Table::INLINE->{"name_lc"}{"default"}->($_[0])
ABresult
1X1
011
000
143 0 ▶ ref_count {if (@_ > 1){$_[0]{'ref_count'}=eval {$INLINE->{'ref_count'}->{
Subroutine ref_count: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
144 0 ▶ 'isa'}->($_[1])};Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
145 0 'invalid (DBIx::Model::Table::ref_count) value: '.$@)if $@;return $_[0]}$_[0
146 0 ▶ ]{'ref_count'}//= eval {$INLINE->{'ref_count'}->{'isa'}->($INLINE->{
Condition0%0/3
$_[0]{"ref_count"} //= eval { do { $DBIx::Model::Table::INLINE->{"ref_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"ref_count"}{"default"}) } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"ref_count"} //= eval { do { $DBIx::Model::Table::INLINE->{"ref_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"ref_count"}{"default"}) } }
$_[0]{"ref_count"} eval { do { $DBIx::Model::Table::INLINE->{"ref_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"ref_count"}{"default"}) } }
Truth table0%0/3
A //= B
A= $_[0]{"ref_count"}B= eval { do { $DBIx::Model::Table::INLINE->{"ref_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"ref_count"}{"default"}) } }
ABresult
1X1
011
000
147 0 ▶ 'ref_count'}->{'default'})};Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
148 'invalid (DBIx::Model::Table::ref_count) default value: ' .$@)if $@;$_[0]{
149 0 ▶ 'ref_count'}}sub target_count {if (@_ > 1){$_[0]{'target_count'}=eval {
Subroutine target_count: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
150 0 ▶ $INLINE->{'target_count'}->{'isa'}->($_[1])};Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
151 0 'invalid (DBIx::Model::Table::target_count) value: '.$@)if $@;return $_[0]}
152 0 ▶ $_[0]{'target_count'}//= eval {$INLINE->{'target_count'}->{'isa'}->($INLINE
Condition0%0/3
$_[0]{"target_count"} //= eval { do { $DBIx::Model::Table::INLINE->{"target_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"target_count"}{"default"}) } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"target_count"} //= eval { do { $DBIx::Model::Table::INLINE->{"target_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"target_count"}{"default"}) } }
$_[0]{"target_count"} eval { do { $DBIx::Model::Table::INLINE->{"target_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"target_count"}{"default"}) } }
Truth table0%0/3
A //= B
A= $_[0]{"target_count"}B= eval { do { $DBIx::Model::Table::INLINE->{"target_count"}{"isa"}->($DBIx::Model::Table::INLINE->{"target_count"}{"default"}) } }
ABresult
1X1
011
000
153 0 ▶ ->{'target_count'}->{'default'})};Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
154 'invalid (DBIx::Model::Table::target_count) default value: ' .$@)if $@;$_[0]
155 0 ▶ {'target_count'}}sub type {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'type'}}
Subroutine type: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
156 #>>>
157 ### DO NOT EDIT ABOVE! (generated by Class::Inline v0.0.1)
158  
159 1 1;
« Model/FK.pm ↑ Summary Model/Column.pm »