File Coverage

blib/lib/PPIx/Regexp/Structure/NamedCapture.pm
Criterion Covered Total %
statement 20 20 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 30 31 96.7


line stmt bran cond sub pod time code
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)}smx' )
9             ->print();
10              
11             =head1 INHERITANCE
12              
13             C is a
14             L.
15              
16             C 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             (? ... )
24             (?'NAME' ... )
25             (?P ... )
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     9   59 use strict;
  9         20  
  9         245  
38 9     9   43 use warnings;
  9         16  
  9         209  
39              
40 9     9   51 use Carp;
  9         31  
  9         449  
41              
42 9     9   54 use base qw{ PPIx::Regexp::Structure::Capture };
  9         28  
  9         816  
43              
44 9     9   68 use PPIx::Regexp::Constant qw{ @CARP_NOT };
  9         25  
  9         1868  
45              
46             our $VERSION = '0.088';
47              
48             sub explain {
49 1     1 1 3 my ( $self ) = @_;
50 1         5 return sprintf q,
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             sub name {
63 29     29 1 73 my ( $self ) = @_;
64 29 50       116 my $type = $self->type()
65             or croak 'Programming error - ', __PACKAGE__, ' without type object';
66 29         137 return $type->name();
67             }
68              
69             1;
70              
71             __END__