Regexp/Structure/Main.pm

filter: Statementstmt 100% 26 / 26 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 95.2% 40 / 42 CC 6 SCAR 11.0
CC
6
Cov
94%
delimiters
5.0
interpolates
2.0
BEGIN
1.0
CRAP 3.0
« Regexp/Token/Whitespace.pm ↑ Summary Regexp/Support.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Structure::Main - Represent a regular expression proper, or a substitution
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{foo}smx' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Structure::Main> is a
14 L<PPIx::Regexp::Structure|PPIx::Regexp::Structure>.
15  
16 C<PPIx::Regexp::Structure::Main> is the parent of
17 L<PPIx::Regexp::Structure::Regexp|PPIx::Regexp::Structure::Regexp> and
18 L<PPIx::Regexp::Structure::Replacement|PPIx::Regexp::Structure::Replacement>.
19  
20 =head1 DESCRIPTION
21  
22 This abstract class represents one of the top-level structures in the
23 expression. Both
24 L<PPIx::Regexp::Structure::Regexp|PPIx::Regexp::Structure::Regexp> and
25 L<PPIx::Regexp::Structure::Replacement|PPIx::Regexp::Structure::Replacement>
26 are derived from it.
27  
28 =head1 METHODS
29  
30 This class provides the following public methods. Methods not documented
31 here are private, and unsupported in the sense that the author reserves
32 the right to change or remove them without notice.
33  
34 =cut
35  
36 package PPIx::Regexp::Structure::Main;
37  
38 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 9 ▶use base qw{ PPIx::Regexp::Structure };
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 9 ▶use PPIx::Regexp::Constant qw{ @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 9 our $VERSION = '0.092';
46  
47 =head2 delimiters
48  
49 This method returns a string representing the delimiters of a regular
50 expression or substitution string. In the case of something like
51 C<s/foo/bar/>, it will return '//' for both the regular expression and
52 the replacement.
53  
54 =cut
55  
56 152 ▶sub delimiters {
Subroutine delimiters: called CC=5 SCAR=16.1
Pod documented
57 152 my ( $self ) = @_;
58 152 my @delims;
59 152 foreach my $method ( qw{ start finish } ) {
60 304 push @delims, undef;
61 304 ▶ defined ( my $obj = $self->$method() )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $obj = $self->$method) or next 301 3 304
62 or next;
63 301 ▶ defined ( my $str = $obj->content() )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $str = $obj->content) or next 301 0 301
64 or next;
65 301 $delims[-1] = $str;
66 }
67 152 ▶ defined ( $delims[0] )
Branch: 1 branch
BranchTrueFalseTotal
defined $delims[0] or $delims[0] = $delims[1] 149 3 152
68 or $delims[0] = $delims[1];
69 152 return $delims[0] . $delims[1];
70 }
71  
72 =head2 interpolates
73  
74 This method returns true if the regular expression or replacement
75 interpolates, and false otherwise. All it really does is to check
76 whether the ending delimiter is a single quote.
77  
78 =cut
79  
80 3 ▶sub interpolates {
Subroutine interpolates: called CC=2 SCAR=7.1
Pod documented
81 3 my ( $self ) = @_;
82 3 ▶ my $finish = $self->finish( 0 ) or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $finish = $self->finish(0) or return 1 3 0 3
83 3 return q<'> ne $finish->content();
84 }
85  
86 9 1;
87  
88 __END__
« Regexp/Token/Whitespace.pm ↑ Summary Regexp/Support.pm »