Regexp/Structure/NamedCapture.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 96.9% 32 / 33 CC 2 SCAR 2.3
CC
2
Cov
96%
name
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Regexp/Token/CharClass/POSIX/Unknown.pm ↑ Summary Regexp/Structure/Replacement.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Structure::NamedCapture - Represent a named capture
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{(?<foo>foo)}smx' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Structure::NamedCapture> is a
14 L<PPIx::Regexp::Structure::Capture|PPIx::Regexp::Structure::Capture>.
15  
16 C<PPIx::Regexp::Structure::NamedCapture> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This class represents a named capture. Its content will be something
21 like one of the following:
22  
23 (?<NAME> ... )
24 (?'NAME' ... )
25 (?P<NAME> ... )
26  
27 =head1 METHODS
28  
29 This class provides the following public methods. Methods not documented
30 here are private, and unsupported in the sense that the author reserves
31 the right to change or remove them without notice.
32  
33 =cut
34  
35 package PPIx::Regexp::Structure::NamedCapture;
36  
37 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 9 ▶use base qw{ PPIx::Regexp::Structure::Capture };
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 9 ▶use PPIx::Regexp::Constant qw{ @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 9 our $VERSION = '0.092';
47  
48 1 ▶sub explain {
Subroutine explain: called CC=1 SCAR=0.0
Pod documented
49 1 my ( $self ) = @_;
50 1 return sprintf q<Named capture group '%s' (number %d)>,
51 $self->name(), $self->number();
52 }
53  
54 =head2 name
55  
56 my $name = $element->name();
57  
58 This method returns the name of the capture.
59  
60 =cut
61  
62 29 ▶sub name {
Subroutine name: called CC=2 SCAR=7.1
Pod documented
63 29 my ( $self ) = @_;
64 29 ▶ my $type = $self->type()
Branch: 1 branch
BranchTrueFalseTotal
my $type = $self->type or croak("Programming error - ", __PACKAGE__, " without type object") 29 0 29
65 or croak 'Programming error - ', __PACKAGE__, ' without type object';
66 29 return $type->name();
67 }
68  
69 9 1;
70  
71 __END__
« Regexp/Token/CharClass/POSIX/Unknown.pm ↑ Summary Regexp/Structure/Replacement.pm »