Perlish/Smatch/Value.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod n/a totaltotal 95.1% 39 / 41 CC 3 SCAR 4.3
CC
3
Cov
97%
_ARRAY
3.0
_UNDEF
2.0
BEGIN
1.0
CRAP 1.5
« Perlish/Smatch/Undef.pm ↑ Summary Perlish/Smatch/Object.pm »
1 package Switch::Perlish::Smatch::Value;
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 'value_cmp';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ## DESC - Call C<Switch::Perlish::Smatch::value_cmp()> with $t and $m.
11 66 ▶sub _VALUE {
Subroutine _VALUE: called CC=1 SCAR=0.0
12 66 my($t, $m) = @_;
13 66 return value_cmp($t, $m);
14 }
15  
16 ## DESC - Return false, a VALUE is always defined.
17 0 ▶sub _UNDEF { return }
Subroutine _UNDEF: not called CC=1 SCAR=6.9
18  
19 ## DESC - Check if what $m points to is the same as $t.
20 1 ▶sub _SCALAR {
Subroutine _SCALAR: called CC=1 SCAR=0.0
21 1 my($t, $m) = @_;
22 1 return value_cmp($t, $$m);
23 }
24  
25 ## DESC - Check if the $t is in $m.
26 2 ▶sub _ARRAY {
Subroutine _ARRAY: called CC=3 SCAR=11.0
27 2 my($t, $m) = @_;
28 Switch::Perlish::Smatch::value_cmp($t, $_) and return 1
29 2 ▶ for @$m;
Branch: 1 branch
BranchTrueFalseTotal
Switch::Perlish::Smatch::value_cmp($t, $_) and return 1 1 5 6
30 1 return;
31 }
32  
33 ## Provide a wrapper sub to test against hash values?
34 ## DESC - Check if the $t exists as a key in $m.
35 2 ▶sub _HASH {
Subroutine _HASH: called CC=1 SCAR=0.0
36 2 my($t, $m) = @_;
37 2 return exists $m->{$t};
38 }
39  
40 ## DESC - Pass $t to &$m.
41 2 ▶sub _CODE {
Subroutine _CODE: called CC=1 SCAR=0.0
42 2 my($t, $m) = @_;
43 2 return $m->($t);
44 }
45  
46 ## DESC - Check if the method $t exists in $m.
47 2 ▶sub _OBJECT {
Subroutine _OBJECT: called CC=1 SCAR=0.0
48 2 my($t, $m) = @_;
49 2 return $m->can($t);
50 }
51  
52 ## DESC - Regexp match $t against $m.
53 2 ▶sub _Regexp {
Subroutine _Regexp: called CC=1 SCAR=0.0
54 2 my($t, $m) = @_;
55 2 return $t =~ /$m/;
56 }
57  
58 11 Switch::Perlish::Smatch->register_package( __PACKAGE__, 'VALUE' );
59  
60 11 1;
61  
62 =pod
63  
64 =head1 NAME
65  
66 Switch::Perlish::Smatch::Value - The C<VALUE> comparatory category package.
67  
68 =head1 VERSION
69  
70 1.0.0 - Initial release.
71  
72 =head1 DESCRIPTION
73  
74 This package provides the default implementation for the C<VALUE> comparator
75 category. For more information on the comparator implementation see.
76 L<Switch::Perlish::Smatch::Comparators/"Value">.
77  
78 =head1 SEE. ALSO
79  
80 L<Switch::Perlish::Smatch>
81  
82 L<Switch::Perlish::Smatch::Comparators>
83  
84 =head1 AUTHOR
85  
86 Dan Brook C<< <mr.daniel.brook@gmail.com> >>
87  
88 =head1 COPYRIGHT
89  
90 Copyright (c) 2006, Dan Brook. All Rights Reserved. This module is free
91 software. It may be used, redistributed and/or modified under the same
92 terms as Perl itself.
93  
94 =cut
« Perlish/Smatch/Undef.pm ↑ Summary Perlish/Smatch/Object.pm »