Smooth/Lookup/substring.pm

filter: Statementstmt 66.6% 20 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 55.3% 26 / 47 CC 4 SCAR 21.5
CC
4
Cov
54%
smooth__lookup__substring
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.6
« Smooth/Fields.pm ↑ Summary Smooth/Helper/Row/Creation.pm »
1 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
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  
5 package DBIx::Class::Smooth::Lookup::substring;
6  
7 # ABSTRACT: Short intro
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.0104';
10  
11 1 ▶use parent 'DBIx::Class::Smooth::Lookup::Util';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use experimental qw/signatures postderef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ▶sub smooth__lookup__substring($self, $column_name, $value, $params, @rest) {
Subroutine smooth__lookup__substring: not called CC=4 SCAR=30.0
Pod undocumented
16 0 $self->smooth__lookup_util__ensure_value_is_scalar('substring', $value);
17 0 $self->smooth__lookup_util__ensure_param_count('substring', $params, { at_least => 1, at_most => 2, regex => qr/^\-?\d+$/ });
18  
19 0 ▶ if(scalar $params->@* < 1 || scalar $params->@* > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$params < 1 or scalar @$params > 2) 0 0 0
Condition0%0/3
scalar @$params < 1 or scalar @$params > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
scalar @$params < 1 or scalar @$params > 2
scalar @$params < 1 scalar @$params > 2
Truth table0%0/3
A or B
A= scalar @$params < 1B= scalar @$params > 2
ABresult
1X1
011
000
20 0 confess sprintf 'substring expects one or two params, got <%s>', join (', ' => $params->@*);
21 }
22 0 my @secure_params = grep { /^\-?\d+$/ } $params->@*;
23 0 ▶ if(scalar @secure_params != scalar $params->@*) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @secure_params != scalar @$params) 0 0 0
24 0 confess sprintf 'substring got faulty params: <%s>', join (', ' => $params->@*);
25 }
26  
27 0 my $param_string = join ', ' => @secure_params;
28  
29 0 return { left_hand_function => { start => 'SUBSTRING(', end => ", $param_string)" } , value => $value };
30 }
31  
32 1 1;
33  
34 __END__
35  
36 =pod
37  
38 =encoding UTF-8
39  
40 =head1 NAME
41  
42 DBIx::Class::Smooth::Lookup::substring - Short intro
43  
44 =head1 VERSION
45  
46 Version 0.0104, released 2020-08-30.
47  
48 =head1 SOURCE
49  
50 L<https://github.com/Csson/p5-DBIx-Class-Smooth>
51  
52 =head1 HOMEPAGE
53  
54 L<https://metacpan.org/release/DBIx-Class-Smooth>
55  
56 =head1 AUTHOR
57  
58 Erik Carlsson <info@code301.com>
59  
60 =head1 COPYRIGHT AND LICENSE
61  
62 This software is copyright (c) 2018 by Erik Carlsson.
63  
64 This is free software; you can redistribute it and/or modify it under
65 the same terms as the Perl 5 programming language system itself.
66  
67 =cut
« Smooth/Fields.pm ↑ Summary Smooth/Helper/Row/Creation.pm »