Smooth/Functions.pm

filter: Statementstmt 47.6% 31 / 65 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 45.4% 10 / 22 Podpod 0.0% 0 / 12 totaltotal 34.1% 41 / 120 CC 11 SCAR 27.0
CC
11
Cov
37%
first_is_voc
56.0
all_is_voc
12.0
drop_last_if_undef
6.0
CRAP 14.9
« Smooth/Helper/ResultSet/Shortcut/AddColumn.pm ↑ Summary Smooth/Schema.pm »
1 2 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::Class::Smooth::Functions;
6  
7 # ABSTRACT: Specify columns
8 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 2 our $VERSION = '0.0108';
10  
11 2 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use List::Util qw/uniq/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use List::SomeUtils qw/any/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Ref::Util qw/is_scalarref is_refref is_arrayref/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Sub::Exporter::Progressive -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
17 exports => [qw/
18 Ascii
19 Bin
20 Char
21 CharLength
22 Concat
23 ConcatWS
24 Elt
25 ExportSet
26 Hex
27 Substring
28 /]
29 2 };
30  
31 2 ▶use experimental qw/postderef signatures/;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 0 ▶sub first_is_voc($function_name, @params) {
Subroutine first_is_voc: not called CC=7 SCAR=40.3
Pod undocumented
34 0 ▶ if (!scalar @params) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @params) 0 0 0
35 0 return { uc $function_name => undef };
36 }
37 0 my $first = shift @params;
38 # If an inner call requires a rendered sql string, the outer call needs to do that as well
39 0 ▶ if (is_refref $first && is_arrayref $$first) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_refref($first) and is_arrayref($$first)) { } 0 0 0
elsif (is_scalarref($first)) { } 0 0 0
Condition0%0/3
is_refref($first) and is_arrayref($$first)
!ll&&!rl&&r
000
MC/DC0%0/2
is_refref($first) and is_arrayref($$first)
is_refref($first) is_arrayref($$first)
Truth table0%0/3
A and B
A= is_refref($first)B= is_arrayref($$first)
ABresult
0X0
100
111
40 0 my $inner_sql_string = $$first->[0];
41 0 ▶ my $sql_string = $inner_sql_string . (scalar @params ? ', ' . join ', ' => @params : '');
Branch: 1 branch
BranchTrueFalseTotal
scalar @params ? : 0 0 0
42 0 return \["@{[ uc $function_name ]}($sql_string)"];
43 }
44 # If you pass the $value_or_columnname as a string ref, then we render an sql string
45 elsif (is_scalarref $first) {
46 0 ▶ my $sql_string = "'$$first'" . (scalar @params ? ', ' . join ', ' => @params : '');
Branch: 1 branch
BranchTrueFalseTotal
scalar @params ? : 0 0 0
47 0 return \["@{[ uc $function_name ]}($sql_string)"];
48 }
49 0 unshift @params => $first;
50 0 return { uc $function_name => \@params };
51 }
52  
53 0 ▶sub all_is_voc($function_name, @params) {
Subroutine all_is_voc: not called CC=3 SCAR=24.8
Pod undocumented
54 0 my $any_is_ref = scalar grep { is_scalarref $_ } @params;
55  
56 0 ▶ if ($any_is_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($any_is_ref) { } 0 0 0
57 0 ▶ my $sql_string = join ', ' => map { is_scalarref $_ ? "'$$_'" : $_ } @params;
Branch: 1 branch
BranchTrueFalseTotal
is_scalarref($_) ? : 0 0 0
58 0 return \["@{[ uc $function_name ]}($sql_string)"];
59 }
60 else {
61 0 return { uc $function_name => \@params };
62 }
63 }
64  
65 0 ▶sub drop_last_if_undef(@params) {
Subroutine drop_last_if_undef: not called CC=2 SCAR=17.9
Pod undocumented
66 0 ▶ if (!defined $params[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $params[-1]) 0 0 0
67 0 pop @params;
68 }
69 0 return @params;
70 }
71  
72 # $voc = Value or column name
73 0 ▶sub Ascii($voc) { return first_is_voc ascii => $voc; }
Subroutine Ascii: not called CC=1 SCAR=6.9
Pod undocumented
74  
75 0 ▶sub Bin($voc) { return first_is_voc bin => $voc; }
Subroutine Bin: not called CC=1 SCAR=6.9
Pod undocumented
76  
77 # # Char does not support USING currently
78 # sub Char($voc, $opts = {}) {
79 # $voc = is_refref $voc ? $$voc->[0] # inner is: \[..]
80 # : is_scalarref $voc && $$voc =~ m/'$/ ? "$$voc" # $voc is eg: \"x'65'"
81 # : is_scalarref $voc ? "'$$voc'" # $voc is eg: \"65"
82 # : $voc;
83 # if ($opts->{'using'}) {
84 # return \["CHAR($voc USING $opts->{'using'})"]
85 # }
86 # return first_is_voc char => $voc;
87  
88 # }
89  
90 0 ▶sub CharLength($voc) { return first_is_voc char_length => $voc; }
Subroutine CharLength: not called CC=1 SCAR=6.9
Pod undocumented
91  
92 0 ▶sub Concat(@list) { return all_is_voc concat => @list; }
Subroutine Concat: not called CC=1 SCAR=6.9
Pod undocumented
93  
94 0 ▶sub ConcatWS($sep, @list) { return all_is_voc concat_ws => $sep, @list; }
Subroutine ConcatWS: not called CC=1 SCAR=6.9
Pod undocumented
95  
96 0 ▶sub Elt($index, @list) { return all_is_voc elt => $index, @list; }
Subroutine Elt: not called CC=1 SCAR=6.9
Pod undocumented
97  
98 0 ▶sub ExportSet($bits, $on, $off, $separator, $number_of_bits) { return all_is_voc export_set => drop_last_if_undef(drop_last_if_undef $bits, $on, $off, $separator, $number_of_bits); }
Subroutine ExportSet: not called CC=1 SCAR=6.9
Pod undocumented
99  
100 0 ▶sub Hex($voc) { return first_is_voc hex => $voc; }
Subroutine Hex: not called CC=1 SCAR=6.9
Pod undocumented
101  
102 0 ▶sub Substring($voc, $pos, $length = undef) { return first_is_voc substring => drop_last_if_undef($voc, $pos, $length); }
Subroutine Substring: not called CC=2 SCAR=17.9
Pod undocumented
103  
104 __END__
« Smooth/Helper/ResultSet/Shortcut/AddColumn.pm ↑ Summary Smooth/Schema.pm »