Perlish/Smatch/Regexp.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 100% 44 / 44 CC 5 SCAR 5.9
CC
5
Cov
100%
_ARRAY
3.0
_HASH
3.0
BEGIN
1.0
CRAP 1.8
« Perlish/Smatch/Scalar.pm ↑ Summary Perlish/Smatch/Undef.pm »
1 package Switch::Perlish::Smatch::Regexp;
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 Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ## DESC - Match $t against $m.
11 2 ▶sub _VALUE {
Subroutine _VALUE: called CC=1 SCAR=0.0
12 2 my($t, $m) = @_;
13 2 return $m =~ $t;
14 }
15  
16 ## DESC - croak("Can't compare Regexp with an undef") # Suggestions welcome.
17 1 ▶sub _UNDEF {
Subroutine _UNDEF: called CC=1 SCAR=0.0
18 1 croak("Can't compare Regexp with an undef");
19 }
20  
21 ## DESC - Check if $m refers to $t.
22 2 ▶sub _SCALAR {
Subroutine _SCALAR: called CC=1 SCAR=0.0
23 2 my($t, $m) = @_;
24 2 return $t == $$m;
25 }
26  
27 ## DESC - Match $t for every element in @$m.
28 2 ▶sub _ARRAY {
Subroutine _ARRAY: called CC=3 SCAR=11.0
29 2 my($t, $m) = @_;
30 $_ =~ $t and return 1
31 2 ▶ for @$m;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /$t/ and return 1 1 3 4
32 return
33 1 }
34  
35 ## DESC - Check if any of keys of %$m match the $t.
36 2 ▶sub _HASH {
Subroutine _HASH: called CC=3 SCAR=11.0
37 2 my($t, $m) = @_;
38 $_ =~ $t and return 1
39 2 ▶ for keys %$m;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /$t/ and return 1 1 2 3
40 1 return;
41 }
42  
43 ## DESC - Pass $t to $m.
44 2 ▶sub _CODE {
Subroutine _CODE: called CC=1 SCAR=0.0
45 2 my($t, $m) = @_;
46 2 return $m->($t);
47 }
48  
49 ## DESC - Match $t against $m's class.
50 2 ▶sub _OBJECT {
Subroutine _OBJECT: called CC=1 SCAR=0.0
51 2 my($t, $m) = @_;
52 2 return ref($m) =~ $t;
53 }
54  
55 ## DESC - Match $m to $t.
56 2 ▶sub _Regexp {
Subroutine _Regexp: called CC=1 SCAR=0.0
57 2 my($t, $m) = @_;
58 2 return $m =~ $t;
59 }
60  
61 11 Switch::Perlish::Smatch->register_package( __PACKAGE__, 'Regexp' );
62  
63 11 1;
64  
65 =pod
66  
67 =head1 NAME
68  
69 Switch::Perlish::Smatch::Regexp - The C<REGEXP> comparatory category package.
70  
71 =head1 VERSION
72  
73 1.0.0 - Initial release.
74  
75 =head1 DESCRIPTION
76  
77 This package provides the default implementation for the C<Regexp> comparator
78 category. For more information on the comparator implementation see.
79 L<Switch::Perlish::Smatch::Comparators/"Regexp">.
80  
81 =head1 SEE. ALSO
82  
83 L<Switch::Perlish::Smatch>
84  
85 L<Switch::Perlish::Smatch::Comparators>
86  
87 =head1 AUTHOR
88  
89 Dan Brook C<< <mr.daniel.brook@gmail.com> >>
90  
91 =head1 COPYRIGHT
92  
93 Copyright (c) 2006, Dan Brook. All Rights Reserved. This module is free
94 software. It may be used, redistributed and/or modified under the same
95  
96 =cut
« Perlish/Smatch/Scalar.pm ↑ Summary Perlish/Smatch/Undef.pm »