File Coverage

blib/lib/Array/Contains/Any.pm
Criterion Covered Total %
statement 37 37 100.0
branch 10 10 100.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 56 56 100.0


line stmt bran cond sub pod time code
1             package Array::Contains::Any;
2              
3 3     3   38 use v5.42;
  3         11  
4 3     3   27 use strict;
  3         23  
  3         118  
5 3     3   14 use warnings;
  3         4  
  3         188  
6 3     3   16 use feature 'keyword_any';
  3         6  
  3         528  
7 3     3   17 no warnings 'experimental::keyword_any';
  3         5  
  3         123  
8 3     3   41 use mro 'c3';
  3         6  
  3         19  
9 3     3   82 use English;
  3         6  
  3         26  
10             our $VERSION = 3.1;
11 3     3   1135 use Carp;
  3         5  
  3         1369  
12              
13             require Exporter;
14              
15             our @ISA = qw(Exporter);
16              
17             our @EXPORT = qw(_contains);
18              
19             sub _contains {
20 10     10   353260 my ($value, $dataset) = @_;
21              
22 10 100       41 if(!defined($value)) {
23 1         128 croak('value is not defined in contains()');
24             }
25              
26 9 100       26 if(!defined($dataset)) {
27 2         351 croak('dataset is not defined in contains()');
28             }
29              
30 7 100       24 if(ref($value) ne '') {
31 1         172 croak('value is not a scalar in contains()');
32             }
33              
34 6 100       21 if(ref($dataset) ne 'ARRAY') {
35 2         322 croak('dataset is not an array reference in contains()');
36             }
37              
38 4 100       7 if(any { $_ eq $value } @{$dataset} ) {
  28         61  
  4         12  
39 2         14 return 1;
40             }
41              
42 2         10 return 0;
43             }
44              
45             1;
46             __END__