Object/Metadata/Column/Bitfield.pm

filter: Statementstmt 58.3% 28 / 48 Branchbran 25.0% 2 / 8 Conditioncond 8.3% 2 / 24 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 66.6% 8 / 12 Podpod 57.1% 4 / 7 totaltotal 39.2% 44 / 112 CC 13 SCAR 20.6
CC
13
Cov
40%
should_inline_value
18.4
select_sql
9.3
method_uses_formatted_key
6.6
CRAP 7.8
« Object/Metadata/Column/Boolean.pm ↑ Summary Object/Metadata/Column/Array.pm »
1 package Rose::DB::Object::Metadata::Column::Bitfield;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Rose::Object::MakeMethods::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Rose::DB::Object::MakeMethods::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Rose::DB::Object::Metadata::Column;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 our @ISA = qw(Rose::DB::Object::Metadata::Column);
10  
11 2 our $VERSION = '0.788';
12  
13 2 __PACKAGE__->add_common_method_maker_argument_names
14 (
15 qw(default bits)
16 );
17  
18 2 Rose::Object::MakeMethods::Generic->make_methods
19 (
20 { preserve_existing => 1 },
21 scalar => [ __PACKAGE__->common_method_maker_argument_names ]
22 );
23  
24 9 ▶sub type { 'bitfield' }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
25  
26 2 foreach my $type (__PACKAGE__->available_method_types)
27 {
28 6 __PACKAGE__->method_maker_type($type => 'bitfield')
29 }
30  
31 # sub dbi_data_type { DBI::SQL_INTEGER() }
32  
33 sub parse_value
34 0 ▶{
Subroutine parse_value: not called CC=2 SCAR=17.9
Pod documented
35 0 my $self = shift;
36 0 my $db = shift;
37 0 my $value = shift;
38 0 ▶ my $bits = shift || $self->bits;
Condition0%0/3
shift() || $self->bits
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $self->bits
shift() $self->bits
Truth table0%0/3
A || B
A= shift()B= $self->bits
ABresult
1X1
011
000
39  
40 0 return $db->parse_bitfield($value, $bits);
41 }
42  
43 sub format_value
44 0 ▶{
Subroutine format_value: not called CC=2 SCAR=17.9
Pod documented
45 0 my $self = shift;
46 0 my $db = shift;
47 0 my $value = shift;
48 0 ▶ my $bits = shift || $self->bits;
Condition0%0/3
shift() || $self->bits
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $self->bits
shift() $self->bits
Truth table0%0/3
A || B
A= shift()B= $self->bits
ABresult
1X1
011
000
49  
50 0 return $db->format_bitfield($value, $bits);
51 }
52  
53 sub init_with_dbi_column_info
54 0 ▶{
Subroutine init_with_dbi_column_info: not called CC=1 SCAR=6.9
Pod undocumented
55 0 my($self, $col_info) = @_;
56  
57 0 $self->SUPER::init_with_dbi_column_info($col_info);
58  
59 0 $self->bits($col_info->{'COLUMN_SIZE'});
60  
61 0 return;
62 }
63  
64 sub should_inline_value
65 0 ▶{
Subroutine should_inline_value: not called CC=5 SCAR=29.1
Pod documented
66 0 my($self, $db, $value) = @_;
67 2 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
68 0 ▶ return (($db->validate_bitfield_keyword($value) && $db->should_inline_bitfield_value($value)) ||
Branch: 1 branch
BranchTrueFalseTotal
$db->validate_bitfield_keyword($value) && $db->should_inline_bitfield_value($value) || $db->keyword_function_calls && $value =~ /^\w+\(.*\)$/ ? : 0 0 0
Condition0%0/9
$db->validate_bitfield_keyword($value) and $db->should_inline_bitfield_value($value) or $db->keyword_function_calls and $value =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$db->validate_bitfield_keyword($value) and $db->should_inline_bitfield_value($value)
!ll&&!rl&&r
000
$db->keyword_function_calls and $value =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/4
$db->validate_bitfield_keyword($value) and $db->should_inline_bitfield_value($value) or $db->keyword_function_calls and $value =~ /^\w+\(.*\)$/
$db->validate_bitfield_keyword($value) $db->should_inline_bitfield_value($value) $db->keyword_function_calls $value =~ /^\w+\(.*\)$/
Truth table0%0/7
A and B or C and D
A= $db->validate_bitfield_keyword($value)B= $db->should_inline_bitfield_value($value)C= $db->keyword_function_callsD= $value =~ /^\w+\(.*\)$/
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
69 ($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0;
70 }
71  
72 sub method_uses_formatted_key
73 2 ▶{
Subroutine method_uses_formatted_key: called CC=4 SCAR=18.9
Pod undocumented
74 2 my($self, $type) = @_;
75 2 ▶ return 1 if($type eq 'get' || $type eq 'set' || $type eq 'get_set');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "get" or $type eq "set" or $type eq "get_set" 2 0 2
Condition33%2/6
$type eq "get" or $type eq "set" or $type eq "get_set"
l!l&&r!l&&!r
020
$type eq "get" or $type eq "set"
l!l&&r!l&&!r
002
MC/DC0%0/3
$type eq "get" or $type eq "set" or $type eq "get_set"
$type eq "get" $type eq "set" $type eq "get_set"
Truth table25%1/4
A or B or C
A= $type eq "get"B= $type eq "set"C= $type eq "get_set"
ABCresult
1XX1
01X1
0011
0000
76 0 return 0;
77 }
78  
79 sub select_sql
80 5 ▶{
Subroutine select_sql: called CC=4 SCAR=22.3
Pod undocumented
81 5 my($self, $db, $table) = @_;
82  
83 5 ▶ if($db)
Branch: 1 branch
BranchTrueFalseTotal
if ($db) { } 0 5 5
84 {
85 0 ▶ if(defined $table)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $table) { } 0 0 0
86 {
87 0 return $db->select_bitfield_column_sql($self->{'name'}, $table);
88 }
89 else
90 {
91 0 ▶ return $self->{'select_sql'}{$db->{'driver'}} ||= $db->select_bitfield_column_sql($self->{'name'});
Condition0%0/3
$self->{"select_sql"}{$db->{"driver"}} ||= $db->select_bitfield_column_sql($self->{"name"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"select_sql"}{$db->{"driver"}} ||= $db->select_bitfield_column_sql($self->{"name"})
$self->{"select_sql"}{$db->{"driver"}} $db->select_bitfield_column_sql($self->{"name"})
Truth table0%0/3
A ||= B
A= $self->{"select_sql"}{$db->{"driver"}}B= $db->select_bitfield_column_sql($self->{"name"})
ABresult
1X1
011
000
92 }
93 }
94 else
95 {
96 5 return $self->{'name'};
97 }
98 }
99  
100 2 1;
101  
102 __END__
« Object/Metadata/Column/Boolean.pm ↑ Summary Object/Metadata/Column/Array.pm »