Smooth/Lookup/Util.pm

filter: Statementstmt 55.5% 20 / 36 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 3 totaltotal 35.1% 26 / 74 CC 11 SCAR 37.9
CC
11
Cov
35%
smooth__lookup_util__ensure_param_count
90.0
smooth__lookup_util__ensure_value_is_arrayref
6.0
smooth__lookup_util__ensure_value_is_scalar
6.0
CRAP 44.2
« Smooth/ResultSetBase.pm ↑ Summary Smooth/Lookup/ident.pm »
1 20 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::Class::Smooth::Lookup::Util;
6  
7 # ABSTRACT: Short intro
8 20 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 20 our $VERSION = '0.0108';
10  
11 20 ▶use parent qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
12 DBIx::Class::Smooth::ResultSetBase
13 20 /;
14 20 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 20 ▶use experimental qw/signatures postderef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 0 ▶sub smooth__lookup_util__ensure_value_is_arrayref($self, $lookup_name, $value) {
Subroutine smooth__lookup_util__ensure_value_is_arrayref: not called CC=2 SCAR=17.9
Pod undocumented
18 0 ▶ if(ref $value ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value ne "ARRAY") 0 0 0
19 0 confess sprintf '<%s> expects an array, got <%s>', $lookup_name, $value;
20 }
21 }
22  
23 0 ▶sub smooth__lookup_util__ensure_value_is_scalar($self, $lookup_name, $value) {
Subroutine smooth__lookup_util__ensure_value_is_scalar: not called CC=2 SCAR=17.9
Pod undocumented
24 0 ▶ if(ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 0 0
25 0 confess sprintf '<%s> expects a scalar, got a <%s>', $lookup_name, ref($value);
26 }
27 }
28  
29 0 ▶sub smooth__lookup_util__ensure_param_count($self, $lookup_name, $params, $ensure_options) {
Subroutine smooth__lookup_util__ensure_param_count: not called CC=9 SCAR=45.0
Pod undocumented
30 0 ▶ my $at_least = delete $ensure_options->{'at_least'} || 0;
Condition0%0/2
delete $ensure_options->{'at_least'} || 0
l!l
00
MC/DC0%0/1
delete $ensure_options->{'at_least'} || 0
delete $ensure_options->{'at_least'}
Truth table0%0/2
A
A= delete $ensure_options->{'at_least'}
Aresult
11
00
31 0 ▶ my $at_most = delete $ensure_options->{'at_most'} || 10000;
Condition0%0/2
delete $ensure_options->{'at_most'} || 10000
l!l
00
MC/DC0%0/1
delete $ensure_options->{'at_most'} || 10000
delete $ensure_options->{'at_most'}
Truth table0%0/2
A
A= delete $ensure_options->{'at_most'}
Aresult
11
00
32 0 ▶ my $regex = delete $ensure_options->{'regex'} || undef;
Condition0%0/2
delete $ensure_options->{'regex'} || undef
l!l
00
MC/DC0%0/1
delete $ensure_options->{'regex'} || undef
delete $ensure_options->{'regex'}
Truth table0%0/2
A
A= delete $ensure_options->{'regex'}
Aresult
11
00
33  
34 0 ▶ if(keys $ensure_options->%*) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$ensure_options) 0 0 0
35 0 confess sprintf "Unexpected keys <%s>", join(', ', sort keys $ensure_options->%*);
36 }
37  
38 0 ▶ if(scalar $params->@* < $at_least || scalar $params->@* > $at_most) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$params < $at_least or scalar @$params > $at_most) 0 0 0
Condition0%0/3
scalar @$params < $at_least or scalar @$params > $at_most
l!l&&r!l&&!r
000
MC/DC0%0/2
scalar @$params < $at_least or scalar @$params > $at_most
scalar @$params < $at_least scalar @$params > $at_most
Truth table0%0/3
A or B
A= scalar @$params < $at_leastB= scalar @$params > $at_most
ABresult
1X1
011
000
39 0 confess sprintf "<%s> expects between $at_least and $at_most params, got %d: <%s>", $lookup_name, scalar ($params->@*), join (', ' => $params->@*);
40 }
41  
42 0 ▶ if($regex) {
Branch: 1 branch
BranchTrueFalseTotal
if ($regex) 0 0 0
43 0 my @correct_params = grep { /$regex/ } $params->@*;
44 0 ▶ if(scalar @correct_params != scalar $params->@*) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @correct_params != scalar @$params) 0 0 0
45 0 confess sprintf '<%s> got faulty params, check documentation: <%s>', $lookup_name, join (', ' => $params->@*);
46 }
47 }
48 }
49  
50 20 1;
51  
52 __END__
« Smooth/ResultSetBase.pm ↑ Summary Smooth/Lookup/ident.pm »