File Coverage

blib/lib/PPIx/Regexp/Structure/Modifier.pm
Criterion Covered Total %
statement 17 18 94.4
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 24 27 88.8


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             PPIx::Regexp::Structure::Modifier - Represent modifying parentheses
4              
5             =head1 SYNOPSIS
6              
7             use PPIx::Regexp::Dumper;
8             PPIx::Regexp::Dumper->new( 'qr{(?i:foo)}smx' )
9             ->print();
10              
11             =head1 INHERITANCE
12              
13             C<PPIx::Regexp::Structure::Modifier> is a
14             L<PPIx::Regexp::Structure|PPIx::Regexp::Structure>.
15              
16             C<PPIx::Regexp::Structure::Modifier> has no descendants.
17              
18             =head1 DESCRIPTION
19              
20             This class represents parentheses that apply modifiers to their contents
21             -- even if there are no modifiers. The latter is to say that C<(?:foo)>
22             also ends up as this class.
23              
24             =head1 METHODS
25              
26             This class provides no public methods beyond those provided by its
27             superclass.
28              
29             =cut
30              
31             package PPIx::Regexp::Structure::Modifier;
32              
33 9     9   70 use strict;
  9         15  
  9         275  
34 9     9   41 use warnings;
  9         11  
  9         389  
35              
36 9     9   34 use base qw{ PPIx::Regexp::Structure };
  9         24  
  9         745  
37              
38 9     9   40 use PPIx::Regexp::Constant qw{ @CARP_NOT };
  9         12  
  9         1647  
39              
40             our $VERSION = '0.091';
41              
42             # This is a kluge for both determining whether the object asserts
43             # modifiers (hence the 'ductype') and determining whether the given
44             # modifier is actually asserted. The signature is the invocant and the
45             # modifier name, which must not be undef. The return is a boolean.
46             sub __ducktype_modifier_asserted {
47 2     2   5 my ( $self, $modifier ) = @_;
48 2         30 foreach my $type ( reverse $self->type() ) {
49 2 50       11 $type->can( '__ducktype_modifier_asserted' )
50             or next;
51 2 50       7 defined( my $val = $type->__ducktype_modifier_asserted( $modifier ) )
52             or next;
53 2         9 return $val;
54             }
55 0           return;
56             }
57              
58             1;
59              
60             __END__
61              
62             =head1 SUPPORT
63              
64             Support is by the author. Please file bug reports at
65             L<https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>,
66             L<https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in
67             electronic mail to the author.
68              
69             =head1 AUTHOR
70              
71             Thomas R. Wyant, III F<wyant at cpan dot org>
72              
73             =head1 COPYRIGHT AND LICENSE
74              
75             Copyright (C) 2009-2023, 2025 by Thomas R. Wyant, III
76              
77             This program is free software; you can redistribute it and/or modify it
78             under the same terms as Perl 5.10.0. For more details, see the full text
79             of the licenses in the directory LICENSES.
80              
81             This program is distributed in the hope that it will be useful, but
82             without any warranty; without even the implied warranty of
83             merchantability or fitness for a particular purpose.
84              
85             =cut
86              
87             # ex: set textwidth=72 :