Perlish/Smatch/Array.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 100% 57 / 57 CC 14 SCAR 10.1
CC
14
Cov
100%
_ARRAY
4.0
_VALUE
3.0
_SCALAR
3.0
CRAP 2.8
« Perlish/Smatch/Hash.pm ↑ Summary Perlish/Smatch/Scalar.pm »
1 package Switch::Perlish::Smatch::Array;
2  
3 11 $VERSION = '1.0.0';
4  
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use Switch::Perlish::Smatch 'smatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ## DESC - Smatch for $m in @$t.
11 2 ▶sub _VALUE {
Subroutine _VALUE: called CC=3 SCAR=11.0
12 2 my($t, $m) = @_;
13 smatch($m, $_) and return 1
14 2 ▶ for @$t;
Branch: 1 branch
BranchTrueFalseTotal
smatch($m, $_) and return 1 1 3 4
15 1 return;
16 }
17  
18 ## DESC - Return false as $t is already defined.
19 1 ▶sub _UNDEF { return }
Subroutine _UNDEF: called CC=1 SCAR=0.0
20  
21 ## DESC - Check if $m points to an element of @$t.
22 2 ▶sub _SCALAR {
Subroutine _SCALAR: called CC=3 SCAR=11.0
23 2 my($t, $m) = @_;
24 \$_ == $m and return 1
25 2 ▶ for @$t;
Branch: 1 branch
BranchTrueFalseTotal
\$_ == $m and return 1 1 10 11
26 1 return;
27 }
28  
29 ## This also doesn't feel right.
30 ## DESC - Smatch for an element of @$m in @$t.
31 4 ▶sub _ARRAY {
Subroutine _ARRAY: called CC=4 SCAR=13.9
32 4 my($t, $m) = @_;
33 4 for my $el (@$t) {
34 smatch($el, $_) and return 1
35 8 ▶ for @$m;
Branch: 1 branch
BranchTrueFalseTotal
smatch($el, $_) and return 1 2 26 28
36 }
37 2 return;
38 }
39  
40 ## This is what I get for JFDI.
41 ## DESC - Check if an element of @$t exists as a key in %$m.
42 2 ▶sub _HASH {
Subroutine _HASH: called CC=3 SCAR=11.0
43 2 my($t, $m) = @_;
44 exists $m->{$_} and return 1
45 2 ▶ for @$t;
Branch: 1 branch
BranchTrueFalseTotal
exists $m->{$_} and return 1 1 4 5
46 1 return;
47 }
48  
49 ## DESC - Call &$m with @$t.
50 2 ▶sub _CODE {
Subroutine _CODE: called CC=1 SCAR=0.0
51 2 my($t, $m) = @_;
52 2 return $m->(@$t);
53 }
54  
55 ## More uncertainty.
56 ## DESC - Check if an element of @$t exists as a method of $m.
57 2 ▶sub _OBJECT {
Subroutine _OBJECT: called CC=3 SCAR=11.0
58 2 my($t, $m) = @_;
59 $m->can($_) and return 1
60 2 ▶ for @$t;
Branch: 1 branch
BranchTrueFalseTotal
$m->can($_) and return 1 1 4 5
61 1 return;
62 }
63  
64 ## DESC - Match $m against the elements of @$t.
65 2 ▶sub _Regexp {
Subroutine _Regexp: called CC=3 SCAR=11.0
66 2 my($t, $m) = @_;
67 /$m/ and return 1
68 2 ▶ for @$t;
Branch: 1 branch
BranchTrueFalseTotal
/$m/ and return 1 1 5 6
69 1 return;
70 }
71  
72 11 Switch::Perlish::Smatch->register_package( __PACKAGE__, 'ARRAY' );
73  
74 11 1;
75  
76 =pod
77  
78 =head1 NAME
79  
80 Switch::Perlish::Smatch::Array - The C<ARRAY> comparatory category package.
81  
82 =head1 VERSION
83  
84 1.0.0 - Initial release.
85  
86 =head1 DESCRIPTION
87  
88 This package provides the default implementation for the C<ARRAY> comparator
89 category. For more information on the comparator implementation see.
90 L<Switch::Perlish::Smatch::Comparators/"Array">.
91  
92 =head1 SEE. ALSO
93  
94 L<Switch::Perlish::Smatch>
95  
96 L<Switch::Perlish::Smatch::Comparators>
97  
98 =head1 AUTHOR
99  
100 Dan Brook C<< <mr.daniel.brook@gmail.com> >>
101  
102 =head1 COPYRIGHT
103  
104 Copyright (c) 2006, Dan Brook. All Rights Reserved. This module is free
105 software. It may be used, redistributed and/or modified under the same
106 terms as Perl itself.
107  
108 =cut
« Perlish/Smatch/Hash.pm ↑ Summary Perlish/Smatch/Scalar.pm »