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 21 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::Class::Smooth::Lookup::Util;
6  
7 # ABSTRACT: Short intro
8 21 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 21 our $VERSION = '0.0104';
10  
11 21 use parent qw/
12 DBIx::Class::Smooth::ResultSetBase
13 21 ▶/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 21 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 21 ▶use experimental qw/signatures postderef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 ▶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 ▶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 ▶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 21 1;
51  
52 __END__
53  
54 =pod
55  
56 =encoding UTF-8
57  
58 =head1 NAME
59  
60 DBIx::Class::Smooth::Lookup::Util - Short intro
61  
62 =head1 VERSION
63  
64 Version 0.0104, released 2020-08-30.
65  
66 =head1 SOURCE
67  
68 L<https://github.com/Csson/p5-DBIx-Class-Smooth>
69  
70 =head1 HOMEPAGE
71  
72 L<https://metacpan.org/release/DBIx-Class-Smooth>
73  
74 =head1 AUTHOR
75  
76 Erik Carlsson <info@code301.com>
77  
78 =head1 COPYRIGHT AND LICENSE
79  
80 This software is copyright (c) 2018 by Erik Carlsson.
81  
82 This is free software; you can redistribute it and/or modify it under
83 the same terms as the Perl 5 programming language system itself.
84  
85 =cut
« Smooth/ResultSetBase.pm ↑ Summary Smooth/Lookup/ident.pm »