Geoffrey/Action/Constraint/Unique.pm

filter: Statementstmt 88.4% 61 / 69 Branchbran 75.0% 15 / 20 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 84.8% 95 / 112 CC 13 SCAR 15.5
CC
13
Cov
84%
add
9.2
drop
3.1
alter
2.2
CRAP 4.7
« Geoffrey/Action/Table.pm ↑ Summary Geoffrey/Utils.pm »
1 package Geoffrey::Action::Constraint::Unique;
2  
3 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Ref::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Time::HiRes qw/ time /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 $Geoffrey::Action::Constraint::Unique::VERSION = '0.000206';
11  
12 6 ▶use parent 'Geoffrey::Role::Action';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 11 ▶sub add {
Subroutine add: called CC=9 SCAR=22.2
Pod documented
15 11 my ( $self, $s_table_name, $hr_params ) = @_;
16 11 my $unique = $self->converter->unique;
17 11 ▶ if ( !$unique ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($unique) 0 11 11
18 0 require Geoffrey::Exception::NotSupportedException;
19 0 Geoffrey::Exception::NotSupportedException::throw_unique( 'add', $self->converter );
20 }
21 11 ▶ if ( !$s_table_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s_table_name) 2 9 11
22 2 require Geoffrey::Exception::RequiredValue;
23 2 Geoffrey::Exception::RequiredValue::throw_table_name( __PACKAGE__ . '::add' );
24 }
25 9 ▶ return () unless $hr_params;
Branch: 1 branch
BranchTrueFalseTotal
unless $hr_params 0 9 9
26 9 ▶ if ( !Ref::Util::is_hashref($hr_params) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Ref::Util::XS::is_hashref($hr_params)) 2 7 9
27 2 require Geoffrey::Exception::General;
28 2 Geoffrey::Exception::General::throw_wrong_ref( __PACKAGE__ . '::add', 'hash' );
29 }
30 7 ▶ if ( !$hr_params->{columns} || scalar @{ $hr_params->{columns} } == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $hr_params->{"columns"} or scalar @{$hr_params->{"columns"};} == 0) 2 5 7
Condition66%2/3
not $hr_params->{"columns"} or scalar @{$hr_params->{"columns"};} == 0
l!l&&r!l&&!r
205
MC/DC50%1/2
not $hr_params->{"columns"} or scalar @{$hr_params->{"columns"};} == 0
not $hr_params->{"columns"} scalar @{$hr_params->{"columns"};} == 0
Truth table66%2/3
not(A) or B
A= not $hr_params->{"columns"}B= scalar @{$hr_params->{"columns"};} == 0
ABresult
1X1
011
000
31 2 require Geoffrey::Exception::RequiredValue;
32 2 Geoffrey::Exception::RequiredValue::throw_table_column( __PACKAGE__ . '::add' );
33 }
34  
35 5 $s_table_name =~ s/"//g;
36 5 my $gentime = time;
37 5 $gentime =~ s/\.//g;
38 5 ▶ $hr_params->{name} ||= 'uidx_' . $s_table_name . '_' . $gentime;
Condition50%1/2
$hr_params->{"name"} ||= 'uidx_' . $s_table_name . '_' . $gentime
l!l
50
MC/DC0%0/1
$hr_params->{"name"} ||= 'uidx_' . $s_table_name . '_' . $gentime
$hr_params->{"name"}
Truth table50%1/2
A
A= $hr_params->{"name"}
Aresult
11
00
39  
40 5 require Geoffrey::Utils;
41 return Geoffrey::Utils::replace_spare( $unique->add,
42 5 ▶ [ $hr_params->{name}, join q/,/, @{ $hr_params->{columns} } ] )
Branch: 1 branch
BranchTrueFalseTotal
if $self->for_table 2 3 5
43 if $self->for_table;
44 return $self->do(
45 Geoffrey::Utils::replace_spare(
46 $unique->append,
47 3 [ $hr_params->{name}, $s_table_name, join q/,/, @{ $hr_params->{columns} } ]
48 )
49 );
50  
51 }
52  
53 1 ▶sub alter {
Subroutine alter: called CC=2 SCAR=7.9
Pod documented
54 1 my ( $self, $s_table_name, $hr_column_params ) = @_;
55 1 my $unique = $self->converter->unique;
56 1 ▶ if ( !$unique ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($unique) 0 1 1
57 0 require Geoffrey::Exception::NotSupportedException;
58 0 Geoffrey::Exception::NotSupportedException::throw_unique( 'alter', $self->converter );
59 }
60 return [
61 1 $self->drop( $s_table_name, $hr_column_params ),
62 $self->append( $s_table_name, $hr_column_params ),
63 ];
64 }
65  
66 2 ▶sub drop {
Subroutine drop: called CC=3 SCAR=11.3
Pod documented
67 2 my ( $self, $s_table_name, $hr_column_params ) = @_;
68 2 my $unique = $self->converter->unique;
69 2 ▶ if ( !$unique ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($unique) 0 2 2
70 0 require Geoffrey::Exception::NotSupportedException;
71 0 Geoffrey::Exception::NotSupportedException::throw_unique( 'drop', $self->converter );
72 }
73 2 ▶ if ( !$s_table_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s_table_name) 1 1 2
74 1 require Geoffrey::Exception::RequiredValue;
75 1 Geoffrey::Exception::RequiredValue::throw_table_name( __PACKAGE__ . '::drop' );
76 }
77 1 require Geoffrey::Utils;
78 return Geoffrey::Utils::replace_spare( $unique->drop,
79 1 [ $s_table_name, $hr_column_params->{name}, ] );
80 }
81  
82 4 ▶sub list_from_schema {
Subroutine list_from_schema: called CC=2 SCAR=7.9
Pod documented
83 4 my ( $self, $schema ) = @_;
84 4 my $unique = $self->converter->unique;
85 4 ▶ if ( !$unique ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($unique) 0 4 4
86 0 require Geoffrey::Exception::NotSupportedException;
87 0 Geoffrey::Exception::NotSupportedException::throw_unique( 'list', $self->converter );
88 }
89 4 return $self->converter->unique_information( $self->do_arrayref( $unique->list($schema) ) );
90 }
91  
92 6 1;
93  
94 __END__
« Geoffrey/Action/Table.pm ↑ Summary Geoffrey/Utils.pm »