Model/Column.pm

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